// 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);
};
import { LogError } from "../../../../core/decorator/LogErrorDecorator";
import { BatchForcedTransferRequest, BatchTransferRequest, ForcedTransferRequest, ForceTransferRequest, ProtectedTransferFromByPartitionRequest, TransferAndLockRequest, TransferRequest, } from "../../request";
import ValidatedRequest from "../../../../core/validation/ValidatedArgs";
import { TransferCommand } from "../../../../app/usecase/command/security/operations/transfer/TransferCommand";
import { TransferAndLockCommand } from "../../../../app/usecase/command/security/operations/transfer/TransferAndLockCommand";
import { ControllerTransferCommand } from "../../../../app/usecase/command/security/operations/transfer/ControllerTransferCommand";
import { ForcedTransferCommand } from "../../../../app/usecase/command/security/operations/transfer/ForcedTransferCommand";
import { BatchTransferCommand } from "../../../../app/usecase/command/security/operations/batch/batchTransfer/BatchTransferCommand";
import { BatchForcedTransferCommand } from "../../../../app/usecase/command/security/operations/batch/batchForcedTransfer/BatchForcedTransferCommand";
import { ProtectedTransferFromByPartitionCommand } from "../../../../app/usecase/command/security/operations/transfer/ProtectedTransferFromByPartitionCommand";
import { BaseSecurityInPort } from "../BaseSecurityInPort";
export class SecurityInPortTransfer extends BaseSecurityInPort {
    async transfer(request) {
        const { securityId, amount, targetId } = request;
        ValidatedRequest.handleValidation("TransferRequest", request);
        return await this.commandBus.execute(new TransferCommand(amount, targetId, securityId));
    }
    async transferAndLock(request) {
        const { securityId, amount, targetId, expirationDate } = request;
        ValidatedRequest.handleValidation("TransferAndLockRequest", request);
        return await this.commandBus.execute(new TransferAndLockCommand(amount, targetId, securityId, expirationDate));
    }
    async controllerTransfer(request) {
        const { securityId, amount, targetId, sourceId } = request;
        ValidatedRequest.handleValidation("ForceTransferRequest", request);
        return await this.commandBus.execute(new ControllerTransferCommand(amount, sourceId, targetId, securityId));
    }
    async forcedTransfer(request) {
        const { securityId, amount, targetId, sourceId } = request;
        ValidatedRequest.handleValidation("ForcedTransferRequest", request);
        return await this.commandBus.execute(new ForcedTransferCommand(sourceId, targetId, amount, securityId));
    }
    async batchTransfer(request) {
        ValidatedRequest.handleValidation("BatchTransferRequest", request);
        return await this.commandBus.execute(new BatchTransferCommand(request.securityId, request.amountList, request.toList));
    }
    async batchForcedTransfer(request) {
        ValidatedRequest.handleValidation("BatchForcedTransferRequest", request);
        return await this.commandBus.execute(new BatchForcedTransferCommand(request.securityId, request.amountList, request.fromList, request.toList));
    }
    async protectedTransferFromByPartition(request) {
        const { securityId, partitionId, sourceId, targetId, amount, deadline, nounce, signature } = request;
        ValidatedRequest.handleValidation("ProtectedTransferFromByPartitionRequest", request);
        return await this.commandBus.execute(new ProtectedTransferFromByPartitionCommand(securityId, partitionId, sourceId, targetId, amount, deadline, nounce, signature));
    }
}
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [TransferRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "transfer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [TransferAndLockRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "transferAndLock", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [ForceTransferRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "controllerTransfer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [ForcedTransferRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "forcedTransfer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [BatchTransferRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "batchTransfer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [BatchForcedTransferRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "batchForcedTransfer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [ProtectedTransferFromByPartitionRequest]),
    __metadata("design:returntype", Promise)
], SecurityInPortTransfer.prototype, "protectedTransferFromByPartition", null);
