// SPDX-License-Identifier: Apache-2.0
import { ControlListFacet__factory, ExternalControlListManagementFacet__factory, MockedBlacklist__factory, MockedWhitelist__factory, } from "@hashgraph/asset-tokenization-contracts";
import { GAS } from "../../../../core/Constants";
import LogService from "../../../../app/service/log/LogService";
export class ControlListOperations {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    async addToControlList(security, targetId, securityId) {
        LogService.logTrace(`Adding account ${targetId.toString()} to a control list`);
        return this.executor.executeContractCall(securityId.toString(), ControlListFacet__factory.createInterface(), "addToControlList", [targetId.toString()], GAS.ADD_TO_CONTROL_LIST);
    }
    async removeFromControlList(security, targetId, securityId) {
        LogService.logTrace(`Removing account ${targetId.toString()} from a control list`);
        return this.executor.executeContractCall(securityId.toString(), ControlListFacet__factory.createInterface(), "removeFromControlList", [targetId.toString()], GAS.REMOVE_FROM_CONTROL_LIST);
    }
    async updateExternalControlLists(security, externalControlListsAddresses, actives, securityId) {
        LogService.logTrace(`Updating External Control Lists for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), ExternalControlListManagementFacet__factory.createInterface(), "updateExternalControlLists", [externalControlListsAddresses.map((address) => address.toString()), actives], GAS.UPDATE_EXTERNAL_CONTROL_LISTS);
    }
    async addExternalControlList(security, externalControlListAddress, securityId) {
        LogService.logTrace(`Adding External Control Lists for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), ExternalControlListManagementFacet__factory.createInterface(), "addExternalControlList", [externalControlListAddress.toString()], GAS.ADD_EXTERNAL_CONTROL_LIST);
    }
    async removeExternalControlList(security, externalControlListAddress, securityId) {
        LogService.logTrace(`Removing External Control Lists for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), ExternalControlListManagementFacet__factory.createInterface(), "removeExternalControlList", [externalControlListAddress.toString()], GAS.REMOVE_EXTERNAL_CONTROL_LIST);
    }
    async addToBlackListMock(contract, targetId, contractId) {
        LogService.logTrace(`Adding address ${targetId.toString()} to external Control black List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), MockedBlacklist__factory.createInterface(), "addToBlacklist", [targetId.toString()], GAS.ADD_TO_BLACK_LIST_MOCK);
    }
    async addToWhiteListMock(contract, targetId, contractId) {
        LogService.logTrace(`Adding address ${targetId.toString()} to external Control white List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), MockedWhitelist__factory.createInterface(), "addToWhitelist", [targetId.toString()], GAS.ADD_TO_WHITE_LIST_MOCK);
    }
    async removeFromBlackListMock(contract, targetId, contractId) {
        LogService.logTrace(`Removing address ${targetId.toString()} from external Control black List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), MockedBlacklist__factory.createInterface(), "removeFromBlacklist", [targetId.toString()], GAS.REMOVE_FROM_BLACK_LIST_MOCK);
    }
    async removeFromWhiteListMock(contract, targetId, contractId) {
        LogService.logTrace(`Removing address ${targetId.toString()} from external Control white List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), MockedWhitelist__factory.createInterface(), "removeFromWhitelist", [targetId.toString()], GAS.REMOVE_FROM_WHITE_LIST_MOCK);
    }
    async createExternalBlackListMock() {
        LogService.logTrace(`Deploying External Control Black List Mock contract`);
        return this.executor.deployContract(MockedBlacklist__factory.bytecode, GAS.CREATE_EXTERNAL_BLACK_LIST_MOCK);
    }
    async createExternalWhiteListMock() {
        LogService.logTrace(`Deploying External Control White List Mock contract`);
        return this.executor.deployContract(MockedWhitelist__factory.bytecode, GAS.CREATE_EXTERNAL_WHITE_LIST_MOCK);
    }
}
