// SPDX-License-Identifier: Apache-2.0
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { ContractCreateTransaction, ContractExecuteTransaction } from "@hiero-ledger/sdk";
import TransactionAdapter from "../TransactionAdapter";
import { TransactionType } from "../TransactionResponseEnums";
import { FactoryOperations } from "./operations/FactoryOperations";
import { TransferOperations } from "./operations/TransferOperations";
import { IssuanceOperations } from "./operations/IssuanceOperations";
import { RoleOperations } from "./operations/RoleOperations";
import { HoldOperations } from "./operations/HoldOperations";
import { ClearingOperations } from "./operations/ClearingOperations";
import { ComplianceOperations } from "./operations/ComplianceOperations";
import { ControlListOperations } from "./operations/ControlListOperations";
import { PauseOperations } from "./operations/PauseOperations";
import { LockOperations } from "./operations/LockOperations";
import { SecurityOperations } from "./operations/SecurityOperations";
import { SecurityMetadataOperations } from "./operations/SecurityMetadataOperations";
import { AmortizationOperations } from "./operations/AmortizationOperations";
export class BaseHederaTransactionAdapter extends TransactionAdapter {
    mirrorNodeAdapter;
    networkService;
    mirrorNodes;
    jsonRpcRelays;
    factories;
    resolvers;
    businessLogicKeysCommon;
    businessLogicKeysEquity;
    businessLogicKeysBond;
    // common
    signer;
    factoryOps;
    transferOps;
    issuanceOps;
    roleOps;
    holdOps;
    clearingOps;
    complianceOps;
    controlListOps;
    pauseOps;
    lockOps;
    securityOps;
    securityMetadataOps;
    amortizationOps;
    constructor(mirrorNodeAdapter, networkService) {
        super();
        this.mirrorNodeAdapter = mirrorNodeAdapter;
        this.networkService = networkService;
        this.factoryOps = new FactoryOperations(this);
        this.transferOps = new TransferOperations(this);
        this.issuanceOps = new IssuanceOperations(this);
        this.roleOps = new RoleOperations(this);
        this.holdOps = new HoldOperations(this);
        this.clearingOps = new ClearingOperations(this);
        this.complianceOps = new ComplianceOperations(this);
        this.controlListOps = new ControlListOperations(this);
        this.pauseOps = new PauseOperations(this);
        this.lockOps = new LockOperations(this);
        this.securityOps = new SecurityOperations(this);
        this.securityMetadataOps = new SecurityMetadataOperations(this);
        this.amortizationOps = new AmortizationOperations(this);
    }
    // ===== Concrete deployContract =====
    async deployContract(bytecodeHex, gas) {
        const hex = bytecodeHex.startsWith("0x") ? bytecodeHex.slice(2) : bytecodeHex;
        const bytecode = Uint8Array.from(Buffer.from(hex, "hex"));
        const contractCreate = new ContractCreateTransaction().setBytecode(bytecode).setGas(gas);
        return this.processTransaction(contractCreate, TransactionType.RECEIPT);
    }
    // ===== Concrete executeContractCall =====
    async executeContractCall(contractId, iface, functionName, params, gasLimit, transactionType = TransactionType.RECEIPT, payableAmountHbar, startDate, 
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    _evmAddress) {
        const encodedHex = iface.encodeFunctionData(functionName, params);
        const encoded = Uint8Array.from(Buffer.from(encodedHex.slice(2), "hex"));
        let tx = new ContractExecuteTransaction().setContractId(contractId).setFunctionParameters(encoded).setGas(gasLimit);
        if (payableAmountHbar)
            tx = tx.setPayableAmount(parseFloat(payableAmountHbar));
        return this.processTransaction(tx, transactionType, startDate);
    }
    // ===== Public getters =====
    getNetworkService() {
        return this.networkService;
    }
    getMirrorNodeAdapter() {
        return this.mirrorNodeAdapter;
    }
    // ===== Operations NOT Smart Contract related =====
    setMirrorNodes(mirrorNodes) {
        if (mirrorNodes)
            this.mirrorNodes = mirrorNodes;
    }
    setJsonRpcRelays(jsonRpcRelays) {
        if (jsonRpcRelays)
            this.jsonRpcRelays = jsonRpcRelays;
    }
    setFactories(factories) {
        if (factories)
            this.factories = factories;
    }
    setResolvers(resolvers) {
        if (resolvers)
            this.resolvers = resolvers;
    }
    setBusinessLogicKeysCommon(businessLogicKeys) {
        if (businessLogicKeys)
            this.businessLogicKeysCommon = businessLogicKeys;
    }
    setBusinessLogicKeysEquity(businessLogicKeys) {
        if (businessLogicKeys)
            this.businessLogicKeysEquity = businessLogicKeys;
    }
    setBusinessLogicKeysBond(businessLogicKeys) {
        if (businessLogicKeys)
            this.businessLogicKeysBond = businessLogicKeys;
    }
    // ===== Factory Operations =====
    async createEquity(...args) {
        return this.factoryOps.createEquity(...args);
    }
    async createBond(...args) {
        return this.factoryOps.createBond(...args);
    }
    async createBondFixedRate(...args) {
        return this.factoryOps.createBondFixedRate(...args);
    }
    async createBondKpiLinkedRate(...args) {
        return this.factoryOps.createBondKpiLinkedRate(...args);
    }
    async createTrexSuiteBond(...args) {
        return this.factoryOps.createTrexSuiteBond(...args);
    }
    async createTrexSuiteEquity(...args) {
        return this.factoryOps.createTrexSuiteEquity(...args);
    }
    // ===== Transfer Operations =====
    async transfer(...args) {
        return this.transferOps.transfer(...args);
    }
    async transferAndLock(...args) {
        return this.transferOps.transferAndLock(...args);
    }
    async redeem(...args) {
        return this.transferOps.redeem(...args);
    }
    async burn(...args) {
        return this.transferOps.burn(...args);
    }
    async controllerTransfer(...args) {
        return this.transferOps.controllerTransfer(...args);
    }
    async forcedTransfer(...args) {
        return this.transferOps.forcedTransfer(...args);
    }
    async controllerRedeem(...args) {
        return this.transferOps.controllerRedeem(...args);
    }
    async operatorTransferByPartition(...args) {
        return this.transferOps.operatorTransferByPartition(...args);
    }
    async batchTransfer(...args) {
        return this.transferOps.batchTransfer(...args);
    }
    async batchForcedTransfer(...args) {
        return this.transferOps.batchForcedTransfer(...args);
    }
    async batchBurn(...args) {
        return this.transferOps.batchBurn(...args);
    }
    // ===== Issuance Operations =====
    async issue(...args) {
        return this.issuanceOps.issue(...args);
    }
    async mint(...args) {
        return this.issuanceOps.mint(...args);
    }
    async batchMint(...args) {
        return this.issuanceOps.batchMint(...args);
    }
    async redeemAtMaturityByPartition(...args) {
        return this.issuanceOps.redeemAtMaturityByPartition(...args);
    }
    async fullRedeemAtMaturity(...args) {
        return this.issuanceOps.fullRedeemAtMaturity(...args);
    }
    // ===== Role Operations =====
    async grantRole(...args) {
        return this.roleOps.grantRole(...args);
    }
    async applyRoles(...args) {
        return this.roleOps.applyRoles(...args);
    }
    async revokeRole(...args) {
        return this.roleOps.revokeRole(...args);
    }
    async renounceRole(...args) {
        return this.roleOps.renounceRole(...args);
    }
    async authorizeOperator(...args) {
        return this.roleOps.authorizeOperator(...args);
    }
    async revokeOperator(...args) {
        return this.roleOps.revokeOperator(...args);
    }
    async authorizeOperatorByPartition(...args) {
        return this.roleOps.authorizeOperatorByPartition(...args);
    }
    async revokeOperatorByPartition(...args) {
        return this.roleOps.revokeOperatorByPartition(...args);
    }
    // ===== Hold Operations =====
    async createHoldByPartition(...args) {
        return this.holdOps.createHoldByPartition(...args);
    }
    async createHoldFromByPartition(...args) {
        return this.holdOps.createHoldFromByPartition(...args);
    }
    async controllerCreateHoldByPartition(...args) {
        return this.holdOps.controllerCreateHoldByPartition(...args);
    }
    async protectedCreateHoldByPartition(...args) {
        return this.holdOps.protectedCreateHoldByPartition(...args);
    }
    async releaseHoldByPartition(...args) {
        return this.holdOps.releaseHoldByPartition(...args);
    }
    async reclaimHoldByPartition(...args) {
        return this.holdOps.reclaimHoldByPartition(...args);
    }
    async executeHoldByPartition(...args) {
        return this.holdOps.executeHoldByPartition(...args);
    }
    // ===== Clearing Operations =====
    async activateClearing(...args) {
        return this.clearingOps.activateClearing(...args);
    }
    async deactivateClearing(...args) {
        return this.clearingOps.deactivateClearing(...args);
    }
    async clearingTransferByPartition(...args) {
        return this.clearingOps.clearingTransferByPartition(...args);
    }
    async clearingTransferFromByPartition(...args) {
        return this.clearingOps.clearingTransferFromByPartition(...args);
    }
    async protectedClearingTransferByPartition(...args) {
        return this.clearingOps.protectedClearingTransferByPartition(...args);
    }
    async approveClearingOperationByPartition(...args) {
        return this.clearingOps.approveClearingOperationByPartition(...args);
    }
    async cancelClearingOperationByPartition(...args) {
        return this.clearingOps.cancelClearingOperationByPartition(...args);
    }
    async reclaimClearingOperationByPartition(...args) {
        return this.clearingOps.reclaimClearingOperationByPartition(...args);
    }
    async clearingRedeemByPartition(...args) {
        return this.clearingOps.clearingRedeemByPartition(...args);
    }
    async clearingRedeemFromByPartition(...args) {
        return this.clearingOps.clearingRedeemFromByPartition(...args);
    }
    async protectedClearingRedeemByPartition(...args) {
        return this.clearingOps.protectedClearingRedeemByPartition(...args);
    }
    async clearingCreateHoldByPartition(...args) {
        return this.clearingOps.clearingCreateHoldByPartition(...args);
    }
    async clearingCreateHoldFromByPartition(...args) {
        return this.clearingOps.clearingCreateHoldFromByPartition(...args);
    }
    async protectedClearingCreateHoldByPartition(...args) {
        return this.clearingOps.protectedClearingCreateHoldByPartition(...args);
    }
    async operatorClearingCreateHoldByPartition(...args) {
        return this.clearingOps.operatorClearingCreateHoldByPartition(...args);
    }
    async operatorClearingRedeemByPartition(...args) {
        return this.clearingOps.operatorClearingRedeemByPartition(...args);
    }
    async operatorClearingTransferByPartition(...args) {
        return this.clearingOps.operatorClearingTransferByPartition(...args);
    }
    // ===== Compliance Operations =====
    async grantKyc(...args) {
        return this.complianceOps.grantKyc(...args);
    }
    async revokeKyc(...args) {
        return this.complianceOps.revokeKyc(...args);
    }
    async addIssuer(...args) {
        return this.complianceOps.addIssuer(...args);
    }
    async removeIssuer(...args) {
        return this.complianceOps.removeIssuer(...args);
    }
    async setRevocationRegistryAddress(...args) {
        return this.complianceOps.setRevocationRegistryAddress(...args);
    }
    async activateInternalKyc(...args) {
        return this.complianceOps.activateInternalKyc(...args);
    }
    async deactivateInternalKyc(...args) {
        return this.complianceOps.deactivateInternalKyc(...args);
    }
    async setOnchainID(...args) {
        return this.complianceOps.setOnchainID(...args);
    }
    async setIdentityRegistry(...args) {
        return this.complianceOps.setIdentityRegistry(...args);
    }
    async setCompliance(...args) {
        return this.complianceOps.setCompliance(...args);
    }
    async updateExternalKycLists(...args) {
        return this.complianceOps.updateExternalKycLists(...args);
    }
    async addExternalKycList(...args) {
        return this.complianceOps.addExternalKycList(...args);
    }
    async removeExternalKycList(...args) {
        return this.complianceOps.removeExternalKycList(...args);
    }
    async grantKycMock(...args) {
        return this.complianceOps.grantKycMock(...args);
    }
    async revokeKycMock(...args) {
        return this.complianceOps.revokeKycMock(...args);
    }
    async createExternalKycListMock() {
        return this.complianceOps.createExternalKycListMock();
    }
    // ===== Control List Operations =====
    async addToControlList(...args) {
        return this.controlListOps.addToControlList(...args);
    }
    async removeFromControlList(...args) {
        return this.controlListOps.removeFromControlList(...args);
    }
    async updateExternalControlLists(...args) {
        return this.controlListOps.updateExternalControlLists(...args);
    }
    async addExternalControlList(...args) {
        return this.controlListOps.addExternalControlList(...args);
    }
    async removeExternalControlList(...args) {
        return this.controlListOps.removeExternalControlList(...args);
    }
    async addToBlackListMock(...args) {
        return this.controlListOps.addToBlackListMock(...args);
    }
    async addToWhiteListMock(...args) {
        return this.controlListOps.addToWhiteListMock(...args);
    }
    async removeFromBlackListMock(...args) {
        return this.controlListOps.removeFromBlackListMock(...args);
    }
    async removeFromWhiteListMock(...args) {
        return this.controlListOps.removeFromWhiteListMock(...args);
    }
    async createExternalBlackListMock() {
        return this.controlListOps.createExternalBlackListMock();
    }
    async createExternalWhiteListMock() {
        return this.controlListOps.createExternalWhiteListMock();
    }
    // ===== Pause Operations =====
    async pause(...args) {
        return this.pauseOps.pause(...args);
    }
    async unpause(...args) {
        return this.pauseOps.unpause(...args);
    }
    async updateExternalPauses(...args) {
        return this.pauseOps.updateExternalPauses(...args);
    }
    async addExternalPause(...args) {
        return this.pauseOps.addExternalPause(...args);
    }
    async removeExternalPause(...args) {
        return this.pauseOps.removeExternalPause(...args);
    }
    async setPausedMock(...args) {
        return this.pauseOps.setPausedMock(...args);
    }
    async createExternalPauseMock() {
        return this.pauseOps.createExternalPauseMock();
    }
    // ===== Lock Operations =====
    async lock(...args) {
        return this.lockOps.lock(...args);
    }
    async release(...args) {
        return this.lockOps.release(...args);
    }
    // ===== Security Operations =====
    async setCoupon(...args) {
        return this.securityOps.setCoupon(...args);
    }
    async cancelCoupon(...args) {
        return this.securityOps.cancelCoupon(...args);
    }
    setRate(...args) {
        return this.securityOps.setRate(...args);
    }
    setInterestRate(...args) {
        return this.securityOps.setInterestRate(...args);
    }
    setImpactData(...args) {
        return this.securityOps.setImpactData(...args);
    }
    addKpiData(...args) {
        return this.securityOps.addKpiData(...args);
    }
    async updateMaturityDate(...args) {
        return this.securityOps.updateMaturityDate(...args);
    }
    addProceedRecipient(...args) {
        return this.securityOps.addProceedRecipient(...args);
    }
    removeProceedRecipient(...args) {
        return this.securityOps.removeProceedRecipient(...args);
    }
    updateProceedRecipientData(...args) {
        return this.securityOps.updateProceedRecipientData(...args);
    }
    async setDividend(...args) {
        return this.securityOps.setDividend(...args);
    }
    async cancelDividend(...args) {
        return this.securityOps.cancelDividend(...args);
    }
    async setVotingRights(...args) {
        return this.securityOps.setVotingRights(...args);
    }
    async cancelVoting(...args) {
        return this.securityOps.cancelVoting(...args);
    }
    async setScheduledBalanceAdjustment(...args) {
        return this.securityOps.setScheduledBalanceAdjustment(...args);
    }
    async cancelScheduledBalanceAdjustment(...args) {
        return this.securityOps.cancelScheduledBalanceAdjustment(...args);
    }
    async takeSnapshot(...args) {
        return this.securityOps.takeSnapshot(...args);
    }
    async triggerPendingScheduledSnapshots(...args) {
        return this.securityOps.triggerPendingScheduledSnapshots(...args);
    }
    async triggerScheduledSnapshots(...args) {
        return this.securityOps.triggerScheduledSnapshots(...args);
    }
    // ===== Security Metadata Operations =====
    async setName(...args) {
        return this.securityMetadataOps.setName(...args);
    }
    async setSymbol(...args) {
        return this.securityMetadataOps.setSymbol(...args);
    }
    async setNominalValue(...args) {
        return this.securityMetadataOps.setNominalValue(...args);
    }
    async setDocument(...args) {
        return this.securityMetadataOps.setDocument(...args);
    }
    async removeDocument(...args) {
        return this.securityMetadataOps.removeDocument(...args);
    }
    async updateConfigVersion(...args) {
        return this.securityMetadataOps.updateConfigVersion(...args);
    }
    async updateConfig(...args) {
        return this.securityMetadataOps.updateConfig(...args);
    }
    async updateResolver(...args) {
        return this.securityMetadataOps.updateResolver(...args);
    }
    async protectPartitions(...args) {
        return this.securityMetadataOps.protectPartitions(...args);
    }
    async unprotectPartitions(...args) {
        return this.securityMetadataOps.unprotectPartitions(...args);
    }
    async protectedRedeemFromByPartition(...args) {
        return this.securityMetadataOps.protectedRedeemFromByPartition(...args);
    }
    async protectedTransferFromByPartition(...args) {
        return this.securityMetadataOps.protectedTransferFromByPartition(...args);
    }
    async freezePartialTokens(...args) {
        return this.securityMetadataOps.freezePartialTokens(...args);
    }
    async unfreezePartialTokens(...args) {
        return this.securityMetadataOps.unfreezePartialTokens(...args);
    }
    async setAddressFrozen(...args) {
        return this.securityMetadataOps.setAddressFrozen(...args);
    }
    async batchSetAddressFrozen(...args) {
        return this.securityMetadataOps.batchSetAddressFrozen(...args);
    }
    async batchFreezePartialTokens(...args) {
        return this.securityMetadataOps.batchFreezePartialTokens(...args);
    }
    async batchUnfreezePartialTokens(...args) {
        return this.securityMetadataOps.batchUnfreezePartialTokens(...args);
    }
    async recoveryAddress(...args) {
        return this.securityMetadataOps.recoveryAddress(...args);
    }
    async addAgent(...args) {
        return this.securityMetadataOps.addAgent(...args);
    }
    async removeAgent(...args) {
        return this.securityMetadataOps.removeAgent(...args);
    }
    async setMaxSupply(...args) {
        return this.securityMetadataOps.setMaxSupply(...args);
    }
    async setAmortization(...args) {
        return this.amortizationOps.setAmortization(...args);
    }
    async cancelAmortization(...args) {
        return this.amortizationOps.cancelAmortization(...args);
    }
    async setAmortizationHold(...args) {
        return this.amortizationOps.setAmortizationHold(...args);
    }
    async releaseAmortizationHold(...args) {
        return this.amortizationOps.releaseAmortizationHold(...args);
    }
}
