Skip to content

Commit

Permalink
fix: event history of avax
Browse files Browse the repository at this point in the history
  • Loading branch information
cauta committed May 16, 2024
1 parent adff117 commit e972011
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/apps/onebox/src/modules/event_history/event_history.service.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { ErrorCode } from '@app/global/global.error';
import {
AvaxEventHistoryRepository,
EthEventHistoryRepository,
PolygonEventHistoryRepository,
} from '@app/shared_modules/event_history/repositories/event_history.repository';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { MonitorNetwork } from '@app/shared_modules/monitor/schemas/monitor.schema';
import { Injectable, Logger } from '@nestjs/common';
import { MonitorService } from '../monitor/monitor.service';
import { User } from '../users/schemas/user.schema';
import {
GetMonitorEventHistoryDto,
MonitorEventHistoryResponseDto,
} from './dto/event_history.dto';
import { MonitorNetwork } from '@app/shared_modules/monitor/schemas/monitor.schema';
import { ErrorCode } from '@app/global/global.error';

@Injectable()
export class EventHistoryService {
private readonly logger = new Logger(EventHistoryService.name);
constructor(
private readonly ethEventHistoryRepository: EthEventHistoryRepository,
private readonly polygonEventHistoryRepository: PolygonEventHistoryRepository,
private readonly avaxEventHistoryRepository: AvaxEventHistoryRepository,
private readonly monitorService: MonitorService,
) {}

Expand Down Expand Up @@ -54,6 +56,16 @@ export class EventHistoryService {
});
}

if (monitor.network === MonitorNetwork.Avalanche) {
return this.avaxEventHistoryRepository
.getEventHistory(monitor.monitorId, request.limit, request.offset)
.then((response) => {
return response.map((event) =>
MonitorEventHistoryResponseDto.from(event),
);
});
}

this.logger.error(`network ${monitor.network} not supported`);
throw ErrorCode.INTERNAL_SERVER_ERROR.asException();
}
Expand Down

0 comments on commit e972011

Please sign in to comment.