fix(identity-service): ensure BlockchainWalletHandler is initialized
- Add BlockchainEventConsumerService to InfrastructureModule - Add BlockchainWalletHandler and MpcKeygenCompletedHandler to ApplicationModule - Inject event handlers into UserApplicationService to force NestJS initialization - This ensures onModuleInit is called for event handlers, enabling Kafka event consumption 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
106137224a
commit
493a76117a
|
|
@ -15,6 +15,8 @@ import { ReferralsController } from '@/api/controllers/referrals.controller';
|
||||||
// Application Services
|
// Application Services
|
||||||
import { UserApplicationService } from '@/application/services/user-application.service';
|
import { UserApplicationService } from '@/application/services/user-application.service';
|
||||||
import { TokenService } from '@/application/services/token.service';
|
import { TokenService } from '@/application/services/token.service';
|
||||||
|
import { BlockchainWalletHandler } from '@/application/event-handlers/blockchain-wallet.handler';
|
||||||
|
import { MpcKeygenCompletedHandler } from '@/application/event-handlers/mpc-keygen-completed.handler';
|
||||||
|
|
||||||
// Domain Services
|
// Domain Services
|
||||||
import {
|
import {
|
||||||
|
|
@ -30,6 +32,7 @@ import { MpcKeyShareRepositoryImpl } from '@/infrastructure/persistence/reposito
|
||||||
import { RedisService } from '@/infrastructure/redis/redis.service';
|
import { RedisService } from '@/infrastructure/redis/redis.service';
|
||||||
import { EventPublisherService } from '@/infrastructure/kafka/event-publisher.service';
|
import { EventPublisherService } from '@/infrastructure/kafka/event-publisher.service';
|
||||||
import { MpcEventConsumerService } from '@/infrastructure/kafka/mpc-event-consumer.service';
|
import { MpcEventConsumerService } from '@/infrastructure/kafka/mpc-event-consumer.service';
|
||||||
|
import { BlockchainEventConsumerService } from '@/infrastructure/kafka/blockchain-event-consumer.service';
|
||||||
import { SmsService } from '@/infrastructure/external/sms/sms.service';
|
import { SmsService } from '@/infrastructure/external/sms/sms.service';
|
||||||
import { BlockchainClientService } from '@/infrastructure/external/blockchain/blockchain-client.service';
|
import { BlockchainClientService } from '@/infrastructure/external/blockchain/blockchain-client.service';
|
||||||
import { MpcClientService, MpcWalletService } from '@/infrastructure/external/mpc';
|
import { MpcClientService, MpcWalletService } from '@/infrastructure/external/mpc';
|
||||||
|
|
@ -53,6 +56,7 @@ import { JwtAuthGuard } from '@/shared/guards/jwt-auth.guard';
|
||||||
RedisService,
|
RedisService,
|
||||||
EventPublisherService,
|
EventPublisherService,
|
||||||
MpcEventConsumerService,
|
MpcEventConsumerService,
|
||||||
|
BlockchainEventConsumerService,
|
||||||
SmsService,
|
SmsService,
|
||||||
MpcClientService,
|
MpcClientService,
|
||||||
MpcWalletService,
|
MpcWalletService,
|
||||||
|
|
@ -64,6 +68,7 @@ import { JwtAuthGuard } from '@/shared/guards/jwt-auth.guard';
|
||||||
RedisService,
|
RedisService,
|
||||||
EventPublisherService,
|
EventPublisherService,
|
||||||
MpcEventConsumerService,
|
MpcEventConsumerService,
|
||||||
|
BlockchainEventConsumerService,
|
||||||
SmsService,
|
SmsService,
|
||||||
MpcClientService,
|
MpcClientService,
|
||||||
MpcWalletService,
|
MpcWalletService,
|
||||||
|
|
@ -92,7 +97,13 @@ export class DomainModule {}
|
||||||
// ============ Application Module ============
|
// ============ Application Module ============
|
||||||
@Module({
|
@Module({
|
||||||
imports: [DomainModule, InfrastructureModule],
|
imports: [DomainModule, InfrastructureModule],
|
||||||
providers: [UserApplicationService, TokenService],
|
providers: [
|
||||||
|
UserApplicationService,
|
||||||
|
TokenService,
|
||||||
|
// Event Handlers - 通过注入到 UserApplicationService 来确保它们被初始化
|
||||||
|
BlockchainWalletHandler,
|
||||||
|
MpcKeygenCompletedHandler,
|
||||||
|
],
|
||||||
exports: [UserApplicationService, TokenService],
|
exports: [UserApplicationService, TokenService],
|
||||||
})
|
})
|
||||||
export class ApplicationModule {}
|
export class ApplicationModule {}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ import { SmsService } from '@/infrastructure/external/sms/sms.service';
|
||||||
import { EventPublisherService } from '@/infrastructure/kafka/event-publisher.service';
|
import { EventPublisherService } from '@/infrastructure/kafka/event-publisher.service';
|
||||||
import { BlockchainClientService } from '@/infrastructure/external/blockchain/blockchain-client.service';
|
import { BlockchainClientService } from '@/infrastructure/external/blockchain/blockchain-client.service';
|
||||||
import { MpcWalletService } from '@/infrastructure/external/mpc';
|
import { MpcWalletService } from '@/infrastructure/external/mpc';
|
||||||
|
import { BlockchainWalletHandler } from '../event-handlers/blockchain-wallet.handler';
|
||||||
|
import { MpcKeygenCompletedHandler } from '../event-handlers/mpc-keygen-completed.handler';
|
||||||
import { ApplicationError } from '@/shared/exceptions/domain.exception';
|
import { ApplicationError } from '@/shared/exceptions/domain.exception';
|
||||||
import { generateRandomIdentity } from '@/shared/utils';
|
import { generateRandomIdentity } from '@/shared/utils';
|
||||||
import { MpcKeygenRequestedEvent } from '@/domain/events';
|
import { MpcKeygenRequestedEvent } from '@/domain/events';
|
||||||
|
|
@ -48,6 +50,9 @@ export class UserApplicationService {
|
||||||
private readonly redisService: RedisService,
|
private readonly redisService: RedisService,
|
||||||
private readonly smsService: SmsService,
|
private readonly smsService: SmsService,
|
||||||
private readonly eventPublisher: EventPublisherService,
|
private readonly eventPublisher: EventPublisherService,
|
||||||
|
// 注入事件处理器以确保它们被 NestJS 实例化并执行 onModuleInit
|
||||||
|
private readonly blockchainWalletHandler: BlockchainWalletHandler,
|
||||||
|
private readonly mpcKeygenCompletedHandler: MpcKeygenCompletedHandler,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue