Skip to content

Commit

Permalink
update: add event history api for mantle
Browse files Browse the repository at this point in the history
  • Loading branch information
cauta committed May 20, 2024
1 parent 96daca4 commit 6118c7a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions app/apps/onebox/src/modules/event_history/event_history.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ export class EventHistoryService {
});
}

if (monitor.network === MonitorNetwork.Mantle) {
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 Expand Up @@ -129,6 +139,21 @@ export class EventHistoryService {
});
}

if (monitor.network === MonitorNetwork.Mantle) {
return this.avaxEventHistoryRepository
.findEventHistoryByMonitorAndHash(
monitor.monitorId,
request.hash,
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 Expand Up @@ -189,6 +214,21 @@ export class EventHistoryService {
});
}

if (monitor.network === MonitorNetwork.Mantle) {
return this.avaxEventHistoryRepository
.findEventHistoryByMonitorAndHash(
monitor.monitorId,
request.associatedAddress,
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 Expand Up @@ -228,6 +268,14 @@ export class EventHistoryService {
});
}

if (monitor.network === MonitorNetwork.Mantle) {
return this.avaxEventHistoryRepository
.findByEventId(request.eventId)
.then((response) => {
return MonitorEventHistoryResponseDto.from(response);
});
}

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

0 comments on commit 6118c7a

Please sign in to comment.