// SPDX-License-Identifier: Apache-2.0
import { AmortizationFacet__factory } from "@hashgraph/asset-tokenization-contracts";
import { GAS } from "../../../../core/Constants";
import LogService from "../../../../app/service/log/LogService";
export class AmortizationOperations {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    async setAmortization(security, recordDate, executionDate, tokensToRedeem, securityId) {
        LogService.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(), AmortizationFacet__factory.createInterface(), "setAmortization", [amortization], GAS.SET_AMORTIZATION);
    }
    async cancelAmortization(security, amortizationId, securityId) {
        LogService.logTrace(`Cancelling amortization: ${amortizationId} for security: ${security}`);
        return this.executor.executeContractCall(securityId.toString(), AmortizationFacet__factory.createInterface(), "cancelAmortization", [amortizationId], GAS.CANCEL_AMORTIZATION);
    }
    async setAmortizationHold(security, amortizationId, tokenHolder, tokenAmount, securityId) {
        LogService.logTrace(`Setting amortization hold: security=${security}, amortizationId=${amortizationId}, tokenHolder=${tokenHolder}, tokenAmount=${tokenAmount}`);
        return this.executor.executeContractCall(securityId.toString(), AmortizationFacet__factory.createInterface(), "setAmortizationHold", [amortizationId, tokenHolder.toString(), tokenAmount.toHexString()], GAS.SET_AMORTIZATION_HOLD);
    }
    async releaseAmortizationHold(security, amortizationId, tokenHolder, securityId) {
        LogService.logTrace(`Releasing amortization hold: security=${security}, amortizationId=${amortizationId}, tokenHolder=${tokenHolder}`);
        return this.executor.executeContractCall(securityId.toString(), AmortizationFacet__factory.createInterface(), "releaseAmortizationHold", [amortizationId, tokenHolder.toString()], GAS.RELEASE_AMORTIZATION_HOLD);
    }
}
