// SPDX-License-Identifier: Apache-2.0
import { ethers } from "ethers";
import { ExternalPauseManagementFacet__factory, MockedExternalPause__factory, } from "@hashgraph/asset-tokenization-contracts";
import { GAS } from "../../../../core/Constants";
import LogService from "../../../../app/service/log/LogService";
export class PauseOperations {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    async pause(security, securityId) {
        LogService.logTrace(`Pausing security: ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), new ethers.Interface(["function pause()"]), "pause", [], GAS.PAUSE);
    }
    async unpause(security, securityId) {
        LogService.logTrace(`Unpausing security: ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), new ethers.Interface(["function unpause()"]), "unpause", [], GAS.PAUSE);
    }
    async updateExternalPauses(security, externalPausesAddresses, actives, securityId) {
        LogService.logTrace(`Updating External Pauses for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), ExternalPauseManagementFacet__factory.createInterface(), "updateExternalPauses", [externalPausesAddresses.map((address) => address.toString()), actives], GAS.UPDATE_EXTERNAL_PAUSES);
    }
    async addExternalPause(security, externalPauseAddress, securityId) {
        LogService.logTrace(`Adding External Pause for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), ExternalPauseManagementFacet__factory.createInterface(), "addExternalPause", [externalPauseAddress.toString()], GAS.ADD_EXTERNAL_PAUSE);
    }
    async removeExternalPause(security, externalPauseAddress, securityId) {
        LogService.logTrace(`Removing External Pause for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), ExternalPauseManagementFacet__factory.createInterface(), "removeExternalPause", [externalPauseAddress.toString()], GAS.REMOVE_EXTERNAL_PAUSE);
    }
    async setPausedMock(contract, paused, contractId) {
        LogService.logTrace(`Setting paused to external pause mock contract ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), MockedExternalPause__factory.createInterface(), "setPaused", [paused], GAS.SET_PAUSED_MOCK);
    }
    async createExternalPauseMock() {
        LogService.logTrace(`Deploying External Pause Mock contract`);
        return this.executor.deployContract(MockedExternalPause__factory.bytecode, GAS.CREATE_EXTERNAL_PAUSE_MOCK);
    }
}
