"use strict";
// SPDX-License-Identifier: Apache-2.0
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PauseOperations = void 0;
const ethers_1 = require("ethers");
const asset_tokenization_contracts_1 = require("@hashgraph/asset-tokenization-contracts");
const Constants_1 = require("../../../../core/Constants");
const LogService_1 = __importDefault(require("../../../../app/service/log/LogService"));
class PauseOperations {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    async pause(security, securityId) {
        LogService_1.default.logTrace(`Pausing security: ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), new ethers_1.ethers.Interface(["function pause()"]), "pause", [], Constants_1.GAS.PAUSE);
    }
    async unpause(security, securityId) {
        LogService_1.default.logTrace(`Unpausing security: ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), new ethers_1.ethers.Interface(["function unpause()"]), "unpause", [], Constants_1.GAS.PAUSE);
    }
    async updateExternalPauses(security, externalPausesAddresses, actives, securityId) {
        LogService_1.default.logTrace(`Updating External Pauses for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ExternalPauseManagementFacet__factory.createInterface(), "updateExternalPauses", [externalPausesAddresses.map((address) => address.toString()), actives], Constants_1.GAS.UPDATE_EXTERNAL_PAUSES);
    }
    async addExternalPause(security, externalPauseAddress, securityId) {
        LogService_1.default.logTrace(`Adding External Pause for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ExternalPauseManagementFacet__factory.createInterface(), "addExternalPause", [externalPauseAddress.toString()], Constants_1.GAS.ADD_EXTERNAL_PAUSE);
    }
    async removeExternalPause(security, externalPauseAddress, securityId) {
        LogService_1.default.logTrace(`Removing External Pause for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ExternalPauseManagementFacet__factory.createInterface(), "removeExternalPause", [externalPauseAddress.toString()], Constants_1.GAS.REMOVE_EXTERNAL_PAUSE);
    }
    async setPausedMock(contract, paused, contractId) {
        LogService_1.default.logTrace(`Setting paused to external pause mock contract ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), asset_tokenization_contracts_1.MockedExternalPause__factory.createInterface(), "setPaused", [paused], Constants_1.GAS.SET_PAUSED_MOCK);
    }
    async createExternalPauseMock() {
        LogService_1.default.logTrace(`Deploying External Pause Mock contract`);
        return this.executor.deployContract(asset_tokenization_contracts_1.MockedExternalPause__factory.bytecode, Constants_1.GAS.CREATE_EXTERNAL_PAUSE_MOCK);
    }
}
exports.PauseOperations = PauseOperations;
