// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { singleton } from "tsyringe";
import Injectable from "../../../core/injectable/Injectable";
import NetworkService from "../network/NetworkService";
import Service from "../Service";
import TransactionService from "../transaction/TransactionService";
import EvmAddress from "../../../domain/context/contract/EvmAddress";
import { HEDERA_FORMAT_ID_REGEX } from "../../../domain/context/shared/HederaId";
import { MirrorNodeAdapter } from "../../../port/out/mirror/MirrorNodeAdapter";
let ContractService = class ContractService extends Service {
    networkService;
    transactionService;
    mirrorNodeAdapter;
    queryBus;
    constructor(networkService = Injectable.resolve(NetworkService), transactionService = Injectable.resolve(TransactionService), mirrorNodeAdapter = Injectable.resolve(MirrorNodeAdapter)) {
        super();
        this.networkService = networkService;
        this.transactionService = transactionService;
        this.mirrorNodeAdapter = mirrorNodeAdapter;
    }
    async getContractEvmAddress(contractId) {
        return new EvmAddress(HEDERA_FORMAT_ID_REGEX.test(contractId)
            ? (await this.mirrorNodeAdapter.getContractInfo(contractId)).evmAddress
            : contractId.toString());
    }
    async getEvmAddressesFromHederaIds(addresses) {
        if (!addresses)
            return [];
        return Promise.all(addresses.map((address) => this.getContractEvmAddress(address.toString())));
    }
};
ContractService = __decorate([
    singleton(),
    __metadata("design:paramtypes", [NetworkService,
        TransactionService,
        MirrorNodeAdapter])
], ContractService);
export default ContractService;
