"use strict";
// Copyright 2021-2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.Client = void 0;
const class_transformer_1 = require("class-transformer");
const client_method_handler_1 = require("./client-method-handler");
const block_1 = require("../types/block");
const types_1 = require("../types");
const api_1 = require("../types/models/api");
/** The Client to interact with nodes. */
class Client {
    /**
     * @param methodHandler The Rust method handler created in `ClientMethodHandler.create()`.
     */
    constructor(methodHandler) {
        this.methodHandler = methodHandler;
    }
    /**
     * @param options The client options.
     */
    static async create(options) {
        return new Client(await client_method_handler_1.ClientMethodHandler.create(options));
    }
    async destroy() {
        return this.methodHandler.destroy();
    }
    // Node routes.
    /**
     * Returns the health of the node.
     * GET /health
     */
    async getHealth(url) {
        const response = await this.methodHandler.callMethod({
            name: 'getHealth',
            data: {
                url,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns the available API route groups of the node.
     * GET /api/routes
     */
    async getRoutes() {
        const response = await this.methodHandler.callMethod({
            name: 'getRoutes',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the node information together with the url of the used node.
     */
    async getNodeInfo() {
        const response = await this.methodHandler.callMethod({
            name: 'getNodeInfo',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns general information about the node.
     * GET /api/core/v3/info
     *
     * @param url The URL of the node.
     * @param auth An authentication object (e.g. JWT).
     */
    async getInfo(url, auth) {
        const response = await this.methodHandler.callMethod({
            name: 'getInfo',
            data: {
                url,
                auth,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the network metrics.
     */
    async getNetworkMetrics() {
        const response = await this.methodHandler.callMethod({
            name: 'getNetworkMetrics',
        });
        return JSON.parse(response).payload;
    }
    // Accounts routes.
    /**
     * Checks if the account is ready to issue a block.
     * GET /api/core/v3/accounts/{bech32Address}/congestion
     */
    async getAccountCongestion(accountId, workScore) {
        const response = await this.methodHandler.callMethod({
            name: 'getAccountCongestion',
            data: {
                accountId,
                workScore,
            },
        });
        return JSON.parse(response).payload;
    }
    // Rewards routes.
    /**
     * Returns the total available Mana rewards of an account or delegation output decayed up to `epochEnd` index
     * provided in the response.
     * Note that rewards for an epoch only become available at the beginning of the next epoch. If the end epoch of a
     * staking feature is equal or greater than the current epoch, the rewards response will not include the potential
     * future rewards for those epochs. `epochStart` and `epochEnd` indicates the actual range for which reward value
     * is returned and decayed for.
     * GET /api/core/v3/rewards/{outputId}
     */
    async getOutputManaRewards(outputId, slotIndex) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutputManaRewards',
            data: {
                outputId,
                slotIndex,
            },
        });
        return JSON.parse(response).payload;
    }
    // Validators routes.
    /**
     * Returns information of all registered validators and if they are active, ordered by their holding stake.
     * GET /api/core/v3/validators
     */
    async getValidators(pageSize, cursor) {
        const response = await this.methodHandler.callMethod({
            name: 'getValidators',
            data: {
                pageSize,
                cursor,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Return information about a staker (registered validator).
     * GET /api/core/v3/validators/{bech32Address}
     */
    async getValidator(accountId) {
        const response = await this.methodHandler.callMethod({
            name: 'getValidator',
            data: {
                accountId,
            },
        });
        return JSON.parse(response).payload;
    }
    // Committee routes.
    /**
     * Returns the information of committee members at the given epoch index. If epoch index is not provided, the
     * current committee members are returned.
     * GET /api/core/v3/committee/?epoch
     */
    async getCommittee(epoch) {
        const response = await this.methodHandler.callMethod({
            name: 'getCommittee',
            data: {
                epoch,
            },
        });
        return JSON.parse(response).payload;
    }
    // Blocks routes.
    /**
     * Returns information that is ideal for attaching a block in the network.
     * GET /api/core/v3/blocks/issuance
     */
    async getIssuance() {
        const response = await this.methodHandler.callMethod({
            name: 'getIssuance',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns the BlockId of the submitted block.
     * POST /api/core/v3/blocks
     *
     * @param block The block to post.
     * @returns The block ID once the block has been posted.
     */
    async postBlock(block) {
        const response = await this.methodHandler.callMethod({
            name: 'postBlock',
            data: {
                block,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns the BlockId of the submitted block.
     * POST /api/core/v3/blocks
     *
     * @param blockBytes The block as raw bytes.
     * @returns The ID of the posted block.
     */
    async postBlockRaw(blockBytes) {
        const response = await this.methodHandler.callMethod({
            name: 'postBlockRaw',
            data: {
                blockBytes,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds a block by its ID and returns it as object.
     * GET /api/core/v3/blocks/{blockId}
     *
     * @param blockId The corresponding block ID of the requested block.
     * @returns The requested block.
     */
    async getBlock(blockId) {
        const response = await this.methodHandler.callMethod({
            name: 'getBlock',
            data: {
                blockId,
            },
        });
        const parsed = JSON.parse(response);
        return (0, block_1.parseBlock)(parsed.payload);
    }
    /**
     * Finds a block by its ID and returns it as raw bytes.
     * GET /api/core/v3/blocks/{blockId}
     *
     * @param blockId The block ID of the requested block.
     * @returns The raw bytes of the requested block.
     */
    async getBlockRaw(blockId) {
        const response = await this.methodHandler.callMethod({
            name: 'getBlockRaw',
            data: {
                blockId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns the metadata of a block.
     * GET /api/core/v3/blocks/{blockId}/metadata
     *
     * @param blockId The corresponding block ID of the requested block metadata.
     * @returns The requested block metadata.
     */
    async getBlockMetadata(blockId) {
        const response = await this.methodHandler.callMethod({
            name: 'getBlockMetadata',
            data: {
                blockId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns a block with its metadata.
     * GET /api/core/v2/blocks/{blockId}/full
     *
     * @param blockId The corresponding block ID of the requested block.
     * @returns The requested block with its metadata.
     */
    async getBlockWithMetadata(blockId) {
        const response = await this.methodHandler.callMethod({
            name: 'getBlockWithMetadata',
            data: {
                blockId,
            },
        });
        return JSON.parse(response).payload;
    }
    // UTXO routes.
    /**
     * Finds an output by its ID and returns it as object.
     * GET /api/core/v3/outputs/{outputId}
     */
    async getOutput(outputId) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutput',
            data: {
                outputId,
            },
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(api_1.OutputResponse, parsed.payload);
    }
    /**
     * Finds an output by its ID and returns it as raw bytes.
     * GET /api/core/v3/outputs/{outputId}
     */
    async getOutputRaw(outputId) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutputRaw',
            data: {
                outputId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds output metadata by output ID.
     * GET /api/core/v3/outputs/{outputId}/metadata
     */
    async getOutputMetadata(outputId) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutputMetadata',
            data: {
                outputId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds an output with its metadata by output ID.
     * GET /api/core/v3/outputs/{outputId}/full
     */
    async getOutputWithMetadata(outputId) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutputWithMetadata',
            data: {
                outputId,
            },
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(api_1.OutputWithMetadataResponse, parsed.payload);
    }
    /**
     * Returns the earliest confirmed block containing the transaction with the given ID.
     * GET /api/core/v3/transactions/{transactionId}/included-block
     *
     * @param transactionId The ID of the transaction.
     * @returns The included block that contained the transaction.
     */
    async getIncludedBlock(transactionId) {
        const response = await this.methodHandler.callMethod({
            name: 'getIncludedBlock',
            data: {
                transactionId,
            },
        });
        const parsed = JSON.parse(response);
        return (0, block_1.parseBlock)(parsed.payload);
    }
    /**
     * Returns the earliest confirmed block containing the transaction with the given ID, as raw bytes.
     * GET /api/core/v3/transactions/{transactionId}/included-block
     *
     * @param transactionId The ID of the transaction.
     * @returns The included block that contained the transaction.
     */
    async getIncludedBlockRaw(transactionId) {
        const response = await this.methodHandler.callMethod({
            name: 'getIncludedBlockRaw',
            data: {
                transactionId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Returns the metadata of the earliest block containing the tx that was confirmed.
     * GET /api/core/v3/transactions/{transactionId}/included-block/metadata
     *
     * @param transactionId The ID of the transaction.
     * @returns The included block that contained the transaction.
     */
    async getIncludedBlockMetadata(transactionId) {
        const response = await this.methodHandler.callMethod({
            name: 'getIncludedBlockMetadata',
            data: {
                transactionId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds the metadata of a transaction.
     * GET /api/core/v3/transactions/{transactionId}/metadata
     *
     * @param transactionId The ID of the transaction.
     * @returns The transaction metadata.
     */
    async getTransactionMetadata(transactionId) {
        const response = await this.methodHandler.callMethod({
            name: 'getTransactionMetadata',
            data: {
                transactionId,
            },
        });
        return JSON.parse(response).payload;
    }
    // Commitments routes.
    /**
     * Finds a slot commitment by its ID and returns it as object.
     * GET /api/core/v3/commitments/{commitmentId}
     *
     * @param commitmentId Commitment ID of the commitment to look up.
     * @returns The commitment.
     */
    async getCommitment(commitmentId) {
        const response = await this.methodHandler.callMethod({
            name: 'getCommitment',
            data: {
                commitmentId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds a slot commitment by its ID and returns it as raw bytes.
     * GET /api/core/v3/commitments/{commitmentId}
     *
     * @param commitmentId Commitment ID of the commitment to look up.
     * @returns The commitment as raw bytes.
     */
    async getCommitmentRaw(commitmentId) {
        const response = await this.methodHandler.callMethod({
            name: 'getCommitmentRaw',
            data: {
                commitmentId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get all UTXO changes of a given slot by slot commitment ID.
     * GET /api/core/v3/commitments/{commitmentId}/utxo-changes
     *
     * @param commitmentId Commitment ID of the commitment to look up.
     * @returns The UTXO changes.
     */
    async getUtxoChanges(commitmentId) {
        const response = await this.methodHandler.callMethod({
            name: 'getUtxoChanges',
            data: {
                commitmentId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get all full UTXO changes of a given slot by slot commitment ID.
     * GET /api/core/v3/commitments/{commitmentId}/utxo-changes/full
     *
     * @param commitmentId Commitment ID of the commitment to look up.
     * @returns The UTXO changes.
     */
    async getUtxoChangesFull(commitmentId) {
        const response = await this.methodHandler.callMethod({
            name: 'getUtxoChangesFull',
            data: {
                commitmentId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds a slot commitment by slot index and returns it as object.
     * GET /api/core/v3/commitments/by-slot/{slot}
     *
     * @param slot Index of the commitment to look up.
     * @returns The commitment.
     */
    async getCommitmentBySlot(slot) {
        const response = await this.methodHandler.callMethod({
            name: 'getCommitmentBySlot',
            data: {
                slot,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Finds a slot commitment by slot index and returns it as raw bytes.
     * GET /api/core/v3/commitments/by-slot/{slot}
     *
     * @param slot Index of the commitment to look up.
     * @returns The commitment as raw bytes.
     */
    async getCommitmentBySlotRaw(slot) {
        const response = await this.methodHandler.callMethod({
            name: 'getCommitmentBySlotRaw',
            data: {
                slot,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get all UTXO changes of a given slot by its index.
     * GET /api/core/v3/commitments/by-slot/{slot}/utxo-changes
     *
     * @param slot Index of the commitment to look up.
     * @returns The UTXO changes.
     */
    async getUtxoChangesBySlot(slot) {
        const response = await this.methodHandler.callMethod({
            name: 'getUtxoChangesBySlot',
            data: {
                slot,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get all full UTXO changes of a given slot by its index.
     * GET /api/core/v3/commitments/by-slot/{slot}/utxo-changes/full
     *
     * @param slot Index of the commitment to look up.
     * @returns The UTXO changes.
     */
    async getUtxoChangesFullBySlot(slot) {
        const response = await this.methodHandler.callMethod({
            name: 'getUtxoChangesFullBySlot',
            data: {
                slot,
            },
        });
        return JSON.parse(response).payload;
    }
    // High level API routes.
    /**
     * Fetch OutputResponse from given output IDs. Requests are sent in parallel.
     */
    async getOutputs(outputIds) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutputs',
            data: {
                outputIds,
            },
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(api_1.OutputResponse, parsed.payload);
    }
    /**
     * Get outputs from provided output IDs (requests are sent
     * in parallel and errors are ignored, can be useful for spent outputs)
     *
     * @param outputIds An array of output IDs.
     * @returns An array of corresponding output responses.
     */
    async getOutputsIgnoreNotFound(outputIds) {
        const response = await this.methodHandler.callMethod({
            name: 'getOutputsIgnoreNotFound',
            data: {
                outputIds,
            },
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(api_1.OutputResponse, parsed.payload);
    }
    /**
     * Find blocks by their IDs.
     *
     * @param blockIds An array of `BlockId`s.
     * @returns An array of corresponding blocks.
     */
    async findBlocks(blockIds) {
        const response = await this.methodHandler.callMethod({
            name: 'findBlocks',
            data: {
                blockIds,
            },
        });
        const parsed = JSON.parse(response);
        return parsed.payload.map((p) => (0, block_1.parseBlock)(p));
    }
    /**
     * Find inputs from addresses for a given amount (useful for offline signing).
     *
     * @param addresses A list of included addresses.
     * @param amount The amount to find inputs for.
     * @returns An array of UTXO inputs.
     */
    async findInputs(addresses, amount) {
        const response = await this.methodHandler.callMethod({
            name: 'findInputs',
            data: {
                addresses,
                amount: Number(amount),
            },
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(types_1.UTXOInput, parsed.payload);
    }
    // Other routes.
    /**
     * Build an unsigned block.
     *
     * @param issuerId The identifier of the block issuer account.
     * @param payload The payload to post.
     * @returns The block ID followed by the block containing the payload.
     */
    async buildBasicBlock(issuerId, payload) {
        const response = await this.methodHandler.callMethod({
            name: 'buildBasicBlock',
            data: {
                issuerId,
                payload,
            },
        });
        const parsed = JSON.parse(response);
        return (0, block_1.parseUnsignedBlock)(parsed.payload);
    }
    /**
     * Get a node candidate from the healthy node pool.
     */
    async getNode() {
        const response = await this.methodHandler.callMethod({
            name: 'getNode',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the ID of the network the node is connected to.
     */
    async getNetworkId() {
        const response = await this.methodHandler.callMethod({
            name: 'getNetworkId',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the Bech32 HRP (human readable part) of the network the node is connected to.
     */
    async getBech32Hrp() {
        const response = await this.methodHandler.callMethod({
            name: 'getBech32Hrp',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the token supply.
     */
    async getTokenSupply() {
        return BigInt((await this.getProtocolParameters()).tokenSupply);
    }
    /**
     * Get the protocol parameters.
     */
    async getProtocolParameters() {
        const response = await this.methodHandler.callMethod({
            name: 'getProtocolParameters',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Converts an address to its bech32 representation
     *
     * @param address An address.
     * @param bech32Hrp The Bech32 HRP (human readable part) to be used.
     * @returns The corresponding Bech32 address.
     */
    async addressToBech32(address, bech32Hrp) {
        const response = await this.methodHandler.callMethod({
            name: 'addressToBech32',
            data: {
                address,
                bech32Hrp,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Return the unhealthy nodes.
     */
    async unhealthyNodes() {
        const response = await this.methodHandler.callMethod({
            name: 'unhealthyNodes',
        });
        return JSON.parse(response).payload;
    }
    /**
     * Build a basic output.
     *
     * @param params An instance of `BasicOutputBuilderParams`.
     */
    async buildBasicOutput(params) {
        if (params.amount && typeof params.amount === 'bigint') {
            params.amount = params.amount.toString(10);
        }
        const response = await this.methodHandler.callMethod({
            name: 'buildBasicOutput',
            data: params,
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(block_1.BasicOutput, parsed.payload);
    }
    /**
     * Build an account output.
     *
     * @param params An instance of `AccountOutputBuilderParams`.
     */
    async buildAccountOutput(params) {
        if (params.amount && typeof params.amount === 'bigint') {
            params.amount = params.amount.toString(10);
        }
        const response = await this.methodHandler.callMethod({
            name: 'buildAccountOutput',
            data: params,
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(block_1.AccountOutput, parsed.payload);
    }
    /**
     * Build a foundry output.
     *
     * @param params An instance of `FoundryOutputBuilderParams`.
     */
    async buildFoundryOutput(params) {
        if (params.amount && typeof params.amount === 'bigint') {
            params.amount = params.amount.toString(10);
        }
        const response = await this.methodHandler.callMethod({
            name: 'buildFoundryOutput',
            data: params,
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(block_1.FoundryOutput, parsed.payload);
    }
    /**
     * Build an NFT output.
     *
     * @param params An instance of `NftOutputBuilderParams`.
     */
    async buildNftOutput(params) {
        if (params.amount && typeof params.amount === 'bigint') {
            params.amount = params.amount.toString(10);
        }
        const response = await this.methodHandler.callMethod({
            name: 'buildNftOutput',
            data: params,
        });
        const parsed = JSON.parse(response);
        return (0, class_transformer_1.plainToInstance)(block_1.NftOutput, parsed.payload);
    }
    /**
     * Listen to MQTT events.
     *
     * @param topics An array of MQTT topics to listen to.
     */
    async listenMqtt(topics, callback) {
        return this.methodHandler.listenMqtt(topics, callback);
    }
    /**
     * Stop listening to certain MQTT events.
     *
     * @param topics An array of MQTT topics to stop listening to.
     */
    async clearMqttListeners(topics) {
        await this.methodHandler.callMethod({
            name: 'clearListeners',
            data: {
                topics,
            },
        });
    }
    /**
     * Calculate the minimum required amount for an output.
     *
     * @param output The output to calculate the minimum amount for.
     * @returns The minimum required amount.
     */
    async computeMinimumOutputAmount(output) {
        const response = await this.methodHandler.callMethod({
            name: 'computeMinimumOutputAmount',
            data: {
                output,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Request funds from a faucet.
     *
     * Example URLs: `https://faucet.testnet.shimmer.network/api/enqueue` or `http://localhost:8091/api/enqueue`.
     *
     * @param url The URL of the faucet.
     * @param address The address to send the funds to.
     * @returns The faucet response.
     */
    async requestFundsFromFaucet(url, address) {
        const response = await this.methodHandler.callMethod({
            name: 'requestFundsFromFaucet',
            data: { url, address },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Extension method which provides request methods for plugins.
     *
     * @param basePluginPath The base path for the plugin eg indexer/v2/ .
     * @param method The http method.
     * @param endpoint The path for the plugin request.
     * @param queryParams Additional query params for the request.
     * @param request The request object.
     * @returns The response json.
     */
    async callPluginRoute(basePluginPath, method, endpoint, queryParams, request) {
        const response = await this.methodHandler.callMethod({
            name: 'callPluginRoute',
            data: {
                basePluginPath,
                method,
                endpoint,
                queryParams: queryParams ?? [],
                request,
            },
        });
        return JSON.parse(response).payload;
    }
    // inx-indexer routes
    /**
     * Fetch account/anchor/basic/delegation/NFT/foundry output IDs based on the given query parameters.
     */
    async outputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'outputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Fetch basic output IDs based on the given query parameters.
     */
    async basicOutputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'basicOutputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output IDs given a list of account query parameters.
     *
     * @param outputQueryParameters `AccountOutputQueryParameters`.
     * @returns A paginated query response of corresponding output IDs.
     */
    async accountOutputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'accountOutputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output ID from an account ID.
     *
     * @param accountId An account ID.
     * @returns The corresponding output ID.
     */
    async accountOutputId(accountId) {
        const response = await this.methodHandler.callMethod({
            name: 'accountOutputId',
            data: {
                accountId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output IDs given a list of anchor query parameters.
     *
     * @param outputQueryParameters `AnchorOutputQueryParameters`.
     * @returns A paginated query response of corresponding output IDs.
     */
    async anchorOutputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'anchorOutputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output ID from an anchor ID.
     *
     * @param anchorId An anchor ID.
     * @returns The corresponding output ID.
     */
    async anchorOutputId(anchorId) {
        const response = await this.methodHandler.callMethod({
            name: 'anchorOutputId',
            data: {
                anchorId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output IDs given a list of delegation query parameters.
     *
     * @param outputQueryParameters `DelegationOutputQueryParameters`.
     * @returns A paginated query response of corresponding output IDs.
     */
    async delegationOutputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'delegationOutputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output ID from an delegation ID.
     *
     * @param delegationId A delegation ID.
     * @returns The corresponding output ID.
     */
    async delegationOutputId(delegationId) {
        const response = await this.methodHandler.callMethod({
            name: 'delegationOutputId',
            data: {
                delegationId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output IDs given a list of Foundry query parameters.
     *
     * @param outputQueryParameters `FoundryOutputQueryParameters`.
     * @returns A paginated query response of corresponding output IDs.
     */
    async foundryOutputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'foundryOutputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output ID from a Foundry ID.
     *
     * @param foundryId A Foundry ID.
     * @returns The corresponding output ID.
     */
    async foundryOutputId(foundryId) {
        const response = await this.methodHandler.callMethod({
            name: 'foundryOutputId',
            data: {
                foundryId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output IDs given a list of NFT query parameters.
     *
     * @param outputQueryParameters `NftOutputQueryParameters`.
     * @returns A paginated query response of corresponding output IDs.
     */
    async nftOutputIds(queryParameters) {
        const response = await this.methodHandler.callMethod({
            name: 'nftOutputIds',
            data: {
                queryParameters,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Get the corresponding output ID from an NFT ID.
     *
     * @param nftId An NFT ID.
     * @returns The corresponding output ID.
     */
    async nftOutputId(nftId) {
        const response = await this.methodHandler.callMethod({
            name: 'nftOutputId',
            data: {
                nftId,
            },
        });
        return JSON.parse(response).payload;
    }
    /**
     * Compute the block ID (Blake2b256 hash of the block bytes) of a block.
     *
     * @param block A block.
     * @returns The corresponding block ID.
     */
    async blockId(block) {
        const response = await this.methodHandler.callMethod({
            name: 'blockId',
            data: {
                block,
            },
        });
        return JSON.parse(response).payload;
    }
}
exports.Client = Client;
//# sourceMappingURL=client.js.map