"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.AmortizationOperations = 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 AmortizationOperations {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    async setAmortization(security, recordDate, executionDate, tokensToRedeem, securityId) {
        LogService_1.default.logTrace(`Setting amortization for security: ${security}, recordDate: ${recordDate}, executionDate: ${executionDate}, tokensToRedeem: ${tokensToRedeem}`);
        const amortization = {
            recordDate: recordDate.toHexString(),
            executionDate: executionDate.toHexString(),
            tokensToRedeem: tokensToRedeem.toHexString(),
        };
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.AmortizationFacet__factory.createInterface(), "setAmortization", [amortization], Constants_1.GAS.SET_AMORTIZATION);
    }
    async cancelAmortization(security, amortizationId, securityId) {
        LogService_1.default.logTrace(`Cancelling amortization: ${amortizationId} for security: ${security}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.AmortizationFacet__factory.createInterface(), "cancelAmortization", [amortizationId], Constants_1.GAS.CANCEL_AMORTIZATION);
    }
    async setAmortizationHold(security, amortizationId, tokenHolder, tokenAmount, securityId) {
        LogService_1.default.logTrace(`Setting amortization hold: security=${security}, amortizationId=${amortizationId}, tokenHolder=${tokenHolder}, tokenAmount=${tokenAmount}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.AmortizationFacet__factory.createInterface(), "setAmortizationHold", [amortizationId, tokenHolder.toString(), tokenAmount.toHexString()], Constants_1.GAS.SET_AMORTIZATION_HOLD);
    }
    async releaseAmortizationHold(security, amortizationId, tokenHolder, securityId) {
        LogService_1.default.logTrace(`Releasing amortization hold: security=${security}, amortizationId=${amortizationId}, tokenHolder=${tokenHolder}`);
        return this.executor.executeContractCall(securityId.toString(), asset_tokenization_contracts_1.AmortizationFacet__factory.createInterface(), "releaseAmortizationHold", [amortizationId, tokenHolder.toString()], Constants_1.GAS.RELEASE_AMORTIZATION_HOLD);
    }
}
exports.AmortizationOperations = AmortizationOperations;
