/**
 * MPC Transfer Initializer Service
 *
 * 在应用启动时将 MPC 签名客户端注入到 ERC20 转账服务中
 * 用于解决循环依赖问题（Domain 层不能直接依赖 Infrastructure 层）
 */

import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { Erc20TransferService } from '@/domain/services/erc20-transfer.service';
import { MpcSigningClient } from '@/infrastructure/mpc';

@Injectable()
export class MpcTransferInitializerService implements OnModuleInit {
  private readonly logger = new Logger(MpcTransferInitializerService.name);

  constructor(
    private readonly erc20TransferService: Erc20TransferService,
    private readonly mpcSigningClient: MpcSigningClient,
  ) {}

  onModuleInit() {
    this.logger.log('[INIT] Injecting MPC Signing Client into ERC20 Transfer Service');
    this.erc20TransferService.setMpcSigningClient(this.mpcSigningClient);
    this.logger.log('[INIT] MPC Signing Client injection complete');
  }
}
