"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.ControlListOperations = void 0;
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 ControlListOperations {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    async addToControlList(security, targetId, securityId) {
        LogService_1.default.logTrace(`Adding account ${targetId.toString()} to a control list`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ControlListFacet__factory.createInterface(), "addToControlList", [targetId.toString()], Constants_1.GAS.ADD_TO_CONTROL_LIST);
    }
    async removeFromControlList(security, targetId, securityId) {
        LogService_1.default.logTrace(`Removing account ${targetId.toString()} from a control list`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ControlListFacet__factory.createInterface(), "removeFromControlList", [targetId.toString()], Constants_1.GAS.REMOVE_FROM_CONTROL_LIST);
    }
    async updateExternalControlLists(security, externalControlListsAddresses, actives, securityId) {
        LogService_1.default.logTrace(`Updating External Control Lists for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ExternalControlListManagementFacet__factory.createInterface(), "updateExternalControlLists", [externalControlListsAddresses.map((address) => address.toString()), actives], Constants_1.GAS.UPDATE_EXTERNAL_CONTROL_LISTS);
    }
    async addExternalControlList(security, externalControlListAddress, securityId) {
        LogService_1.default.logTrace(`Adding External Control Lists for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ExternalControlListManagementFacet__factory.createInterface(), "addExternalControlList", [externalControlListAddress.toString()], Constants_1.GAS.ADD_EXTERNAL_CONTROL_LIST);
    }
    async removeExternalControlList(security, externalControlListAddress, securityId) {
        LogService_1.default.logTrace(`Removing External Control Lists for security ${security.toString()}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.ExternalControlListManagementFacet__factory.createInterface(), "removeExternalControlList", [externalControlListAddress.toString()], Constants_1.GAS.REMOVE_EXTERNAL_CONTROL_LIST);
    }
    async addToBlackListMock(contract, targetId, contractId) {
        LogService_1.default.logTrace(`Adding address ${targetId.toString()} to external Control black List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), asset_tokenization_contracts_1.MockedBlacklist__factory.createInterface(), "addToBlacklist", [targetId.toString()], Constants_1.GAS.ADD_TO_BLACK_LIST_MOCK);
    }
    async addToWhiteListMock(contract, targetId, contractId) {
        LogService_1.default.logTrace(`Adding address ${targetId.toString()} to external Control white List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), asset_tokenization_contracts_1.MockedWhitelist__factory.createInterface(), "addToWhitelist", [targetId.toString()], Constants_1.GAS.ADD_TO_WHITE_LIST_MOCK);
    }
    async removeFromBlackListMock(contract, targetId, contractId) {
        LogService_1.default.logTrace(`Removing address ${targetId.toString()} from external Control black List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), asset_tokenization_contracts_1.MockedBlacklist__factory.createInterface(), "removeFromBlacklist", [targetId.toString()], Constants_1.GAS.REMOVE_FROM_BLACK_LIST_MOCK);
    }
    async removeFromWhiteListMock(contract, targetId, contractId) {
        LogService_1.default.logTrace(`Removing address ${targetId.toString()} from external Control white List mock ${contract.toString()}`);
        return this.executor.executeContractCall(contractId.toString(), asset_tokenization_contracts_1.MockedWhitelist__factory.createInterface(), "removeFromWhitelist", [targetId.toString()], Constants_1.GAS.REMOVE_FROM_WHITE_LIST_MOCK);
    }
    async createExternalBlackListMock() {
        LogService_1.default.logTrace(`Deploying External Control Black List Mock contract`);
        return this.executor.deployContract(asset_tokenization_contracts_1.MockedBlacklist__factory.bytecode, Constants_1.GAS.CREATE_EXTERNAL_BLACK_LIST_MOCK);
    }
    async createExternalWhiteListMock() {
        LogService_1.default.logTrace(`Deploying External Control White List Mock contract`);
        return this.executor.deployContract(asset_tokenization_contracts_1.MockedWhitelist__factory.bytecode, Constants_1.GAS.CREATE_EXTERNAL_WHITE_LIST_MOCK);
    }
}
exports.ControlListOperations = ControlListOperations;
