import { Module } from '@nestjs/common';
import { InfrastructureModule } from '@/infrastructure/infrastructure.module';
import { DomainModule } from '@/domain/domain.module';
import {
  AddressDerivationService,
  DepositDetectionService,
  BalanceQueryService,
  MnemonicVerificationService,
  OutboxPublisherService,
  DepositRepairService,
  MpcTransferInitializerService,
} from './services';
import { MpcKeygenCompletedHandler, WithdrawalRequestedHandler } from './event-handlers';
import { SystemWithdrawalRequestedHandler } from './event-handlers/system-withdrawal-requested.handler';
import { DepositAckConsumerService } from '@/infrastructure/kafka/deposit-ack-consumer.service';
import { HotWalletBalanceScheduler } from './schedulers';

@Module({
  imports: [InfrastructureModule, DomainModule],
  providers: [
    // 应用服务
    AddressDerivationService,
    DepositDetectionService,
    BalanceQueryService,
    MnemonicVerificationService,
    OutboxPublisherService,
    DepositRepairService,
    MpcTransferInitializerService,

    // 事件消费者（依赖 OutboxPublisherService，需要在这里注册）
    DepositAckConsumerService,

    // 事件处理器
    MpcKeygenCompletedHandler,
    WithdrawalRequestedHandler,
    SystemWithdrawalRequestedHandler,

    // 定时任务
    HotWalletBalanceScheduler,
  ],
  exports: [
    AddressDerivationService,
    DepositDetectionService,
    BalanceQueryService,
    MnemonicVerificationService,
    OutboxPublisherService,
    DepositRepairService,
    DepositAckConsumerService,
    MpcKeygenCompletedHandler,
    WithdrawalRequestedHandler,
    SystemWithdrawalRequestedHandler,
  ],
})
export class ApplicationModule {}
