"use strict";
// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SecurityInPortFreeze = void 0;
const LogErrorDecorator_1 = require("../../../../core/decorator/LogErrorDecorator");
const request_1 = require("../../request");
const ValidatedArgs_1 = __importDefault(require("../../../../core/validation/ValidatedArgs"));
const BatchSetAddressFrozenCommand_1 = require("../../../../app/usecase/command/security/operations/batch/batchSetAddressFrozen/BatchSetAddressFrozenCommand");
const BatchFreezePartialTokensCommand_1 = require("../../../../app/usecase/command/security/operations/batch/batchFreezePartialTokens/BatchFreezePartialTokensCommand");
const BatchUnfreezePartialTokensCommand_1 = require("../../../../app/usecase/command/security/operations/batch/batchUnfreezePartialTokens/BatchUnfreezePartialTokensCommand");
const FreezePartialTokensCommand_1 = require("../../../../app/usecase/command/security/operations/freeze/freezePartialTokens/FreezePartialTokensCommand");
const UnfreezePartialTokensCommand_1 = require("../../../../app/usecase/command/security/operations/freeze/unfreezePartialTokens/UnfreezePartialTokensCommand");
const GetFrozenPartialTokensQuery_1 = require("../../../../app/usecase/query/security/freeze/getFrozenPartialTokens/GetFrozenPartialTokensQuery");
const SetAddressFrozenCommand_1 = require("../../../../app/usecase/command/security/operations/freeze/setAddressFrozen/SetAddressFrozenCommand");
const BaseSecurityInPort_1 = require("../BaseSecurityInPort");
class SecurityInPortFreeze extends BaseSecurityInPort_1.BaseSecurityInPort {
    async setAddressFrozen(request) {
        ValidatedArgs_1.default.handleValidation(request_1.SetAddressFrozenRequest.name, request);
        const { securityId, status, targetId } = request;
        return await this.commandBus.execute(new SetAddressFrozenCommand_1.SetAddressFrozenCommand(securityId, status, targetId));
    }
    async batchSetAddressFrozen(request) {
        ValidatedArgs_1.default.handleValidation("BatchSetAddressFrozenRequest", request);
        return await this.commandBus.execute(new BatchSetAddressFrozenCommand_1.BatchSetAddressFrozenCommand(request.securityId, request.freezeList, request.targetList));
    }
    async batchFreezePartialTokens(request) {
        ValidatedArgs_1.default.handleValidation("BatchFreezePartialTokensRequest", request);
        return await this.commandBus.execute(new BatchFreezePartialTokensCommand_1.BatchFreezePartialTokensCommand(request.securityId, request.amountList, request.targetList));
    }
    async batchUnfreezePartialTokens(request) {
        ValidatedArgs_1.default.handleValidation("BatchUnfreezePartialTokensRequest", request);
        return await this.commandBus.execute(new BatchUnfreezePartialTokensCommand_1.BatchUnfreezePartialTokensCommand(request.securityId, request.amountList, request.targetList));
    }
    async freezePartialTokens(request) {
        ValidatedArgs_1.default.handleValidation("FreezePartialTokensRequest", request);
        const { securityId, amount, targetId } = request;
        return await this.commandBus.execute(new FreezePartialTokensCommand_1.FreezePartialTokensCommand(securityId, amount, targetId));
    }
    async unfreezePartialTokens(request) {
        ValidatedArgs_1.default.handleValidation("UnfreezePartialTokensRequest", request);
        const { securityId, amount, targetId } = request;
        return await this.commandBus.execute(new UnfreezePartialTokensCommand_1.UnfreezePartialTokensCommand(securityId, amount, targetId));
    }
    async getFrozenPartialTokens(request) {
        ValidatedArgs_1.default.handleValidation("GetFrozenPartialTokensRequest", request);
        const res = await this.queryBus.execute(new GetFrozenPartialTokensQuery_1.GetFrozenPartialTokensQuery(request.securityId, request.targetId));
        const balance = { value: res.payload.toString() };
        return balance;
    }
}
exports.SecurityInPortFreeze = SecurityInPortFreeze;
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.SetAddressFrozenRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "setAddressFrozen", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.BatchSetAddressFrozenRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "batchSetAddressFrozen", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.BatchFreezePartialTokensRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "batchFreezePartialTokens", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.BatchUnfreezePartialTokensRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "batchUnfreezePartialTokens", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.FreezePartialTokensRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "freezePartialTokens", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.UnfreezePartialTokensRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "unfreezePartialTokens", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.GetFrozenPartialTokensRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortFreeze.prototype, "getFrozenPartialTokens", null);
