From 8593220349c3810deaa00cab81a631a5c7ea8d41 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Sat, 14 Oct 2023 19:13:55 +0400 Subject: [PATCH 1/4] feature: added request info to response --- .../dto/request-time-by-request-id.dto.ts | 20 ++++++++++++------ src/http/request-time/dto/request.dto.ts | 21 +++++++++++++++++++ src/http/request-time/request-time.service.ts | 3 ++- src/jobs/queue-info/queue-info.service.ts | 1 + 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/http/request-time/dto/request.dto.ts diff --git a/src/http/request-time/dto/request-time-by-request-id.dto.ts b/src/http/request-time/dto/request-time-by-request-id.dto.ts index 1cfa5a4..e0923c6 100644 --- a/src/http/request-time/dto/request-time-by-request-id.dto.ts +++ b/src/http/request-time/dto/request-time-by-request-id.dto.ts @@ -1,4 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; +import { RequestDto } from './request.dto'; export class RequestTimeByRequestIdDto { @ApiProperty({ @@ -7,12 +8,6 @@ export class RequestTimeByRequestIdDto { }) ms: number; - @ApiProperty({ - example: 5, - description: 'Request Id', - }) - requestId: string; - @ApiProperty({ example: '2023-10-04T15:14:24.202Z', description: 'Withdrawal At', @@ -27,4 +22,17 @@ export class RequestTimeByRequestIdDto { ms: number; withdrawalAt: string; }; + + @ApiProperty({ + example: { + id: '1', + amountOfStETH: '2', + amountOfShares: '2', + timestamp: '2023-10-04T15:14:24.202Z', + isFinalized: false, + isClaimed: false, + }, + description: 'Request', + }) + request: RequestDto; } diff --git a/src/http/request-time/dto/request.dto.ts b/src/http/request-time/dto/request.dto.ts new file mode 100644 index 0000000..e4fbd57 --- /dev/null +++ b/src/http/request-time/dto/request.dto.ts @@ -0,0 +1,21 @@ +import { WithdrawalRequest } from '../../../storage/queue-info/queue-info.types'; + +export class RequestDto { + id: string; + amountOfStETH: string; + amountOfShares: string; + timestamp: string; + isFinalized: boolean; + isClaimed: boolean; +} + +export const transformToRequestDto = (request: WithdrawalRequest): RequestDto => { + return { + id: request.id.toString(), + amountOfStETH: request.amountOfStETH.toString(), + amountOfShares: request.amountOfStETH.toString(), + timestamp: new Date(request.timestamp.toNumber() * 1000).toISOString(), + isFinalized: request.isFinalized, + isClaimed: request.isClaimed, + }; +}; diff --git a/src/http/request-time/request-time.service.ts b/src/http/request-time/request-time.service.ts index cca1a28..c827046 100644 --- a/src/http/request-time/request-time.service.ts +++ b/src/http/request-time/request-time.service.ts @@ -24,6 +24,7 @@ import { RequestTimeV2Dto } from './dto/request-time-v2.dto'; import { LOGGER_PROVIDER } from '@lido-nestjs/logger'; import { RequestTimeByRequestIdDto } from './dto/request-time-by-request-id.dto'; import { WithdrawalRequest } from '../../storage/queue-info/queue-info.types'; +import { transformToRequestDto } from './dto/request.dto'; @Injectable() export class RequestTimeService { @@ -129,7 +130,7 @@ export class RequestTimeService { ); return { - requestId: request.id.toString(), + request: transformToRequestDto(request), ms: toTimeWithdrawal, withdrawalAt: new Date(requestTimestamp + toTimeWithdrawal).toISOString(), withVEBO: { diff --git a/src/jobs/queue-info/queue-info.service.ts b/src/jobs/queue-info/queue-info.service.ts index 3d16353..9c16c1d 100644 --- a/src/jobs/queue-info/queue-info.service.ts +++ b/src/jobs/queue-info/queue-info.service.ts @@ -63,6 +63,7 @@ export class QueueInfoService { .reverse(); const withdrawalStatuses = await this.contractWithdrawal.getWithdrawalStatus(requestIds); const requests = withdrawalStatuses.map((w, i) => ({ ...w, id: requestIds[i] } as WithdrawalRequest)); + console.log(requests.map((r) => r.id.toString())); this.queueInfoStorageService.setRequests(requests); this.queueInfoStorageService.setStETH(unfinalizedStETH); From 9f236767d91c4cc7d27526c299a3733b42aef53e Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Sat, 14 Oct 2023 19:16:36 +0400 Subject: [PATCH 2/4] feature: rm logs --- src/jobs/queue-info/queue-info.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jobs/queue-info/queue-info.service.ts b/src/jobs/queue-info/queue-info.service.ts index 9c16c1d..3d16353 100644 --- a/src/jobs/queue-info/queue-info.service.ts +++ b/src/jobs/queue-info/queue-info.service.ts @@ -63,7 +63,6 @@ export class QueueInfoService { .reverse(); const withdrawalStatuses = await this.contractWithdrawal.getWithdrawalStatus(requestIds); const requests = withdrawalStatuses.map((w, i) => ({ ...w, id: requestIds[i] } as WithdrawalRequest)); - console.log(requests.map((r) => r.id.toString())); this.queueInfoStorageService.setRequests(requests); this.queueInfoStorageService.setStETH(unfinalizedStETH); From c00289fddf6b3587d05e0155869f6da37bd5516f Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Sun, 15 Oct 2023 14:25:37 +0400 Subject: [PATCH 3/4] feature: rm not needed properties --- .../request-time/dto/request-time-by-request-id.dto.ts | 8 ++++++-- src/http/request-time/dto/request.dto.ts | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/http/request-time/dto/request-time-by-request-id.dto.ts b/src/http/request-time/dto/request-time-by-request-id.dto.ts index e0923c6..96a5754 100644 --- a/src/http/request-time/dto/request-time-by-request-id.dto.ts +++ b/src/http/request-time/dto/request-time-by-request-id.dto.ts @@ -23,14 +23,18 @@ export class RequestTimeByRequestIdDto { withdrawalAt: string; }; + @ApiProperty({ + example: 5, + description: 'Request Id', + }) + requestId: string; + @ApiProperty({ example: { id: '1', amountOfStETH: '2', amountOfShares: '2', timestamp: '2023-10-04T15:14:24.202Z', - isFinalized: false, - isClaimed: false, }, description: 'Request', }) diff --git a/src/http/request-time/dto/request.dto.ts b/src/http/request-time/dto/request.dto.ts index e4fbd57..ed6077a 100644 --- a/src/http/request-time/dto/request.dto.ts +++ b/src/http/request-time/dto/request.dto.ts @@ -5,8 +5,6 @@ export class RequestDto { amountOfStETH: string; amountOfShares: string; timestamp: string; - isFinalized: boolean; - isClaimed: boolean; } export const transformToRequestDto = (request: WithdrawalRequest): RequestDto => { @@ -15,7 +13,5 @@ export const transformToRequestDto = (request: WithdrawalRequest): RequestDto => amountOfStETH: request.amountOfStETH.toString(), amountOfShares: request.amountOfStETH.toString(), timestamp: new Date(request.timestamp.toNumber() * 1000).toISOString(), - isFinalized: request.isFinalized, - isClaimed: request.isClaimed, }; }; From db6a083dc2974b5c0c037481821767fd1495d739 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Sun, 15 Oct 2023 14:27:30 +0400 Subject: [PATCH 4/4] feature: revert id --- src/http/request-time/request-time.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/http/request-time/request-time.service.ts b/src/http/request-time/request-time.service.ts index c827046..dacf68a 100644 --- a/src/http/request-time/request-time.service.ts +++ b/src/http/request-time/request-time.service.ts @@ -130,6 +130,7 @@ export class RequestTimeService { ); return { + requestId: request.id.toString(), request: transformToRequestDto(request), ms: toTimeWithdrawal, withdrawalAt: new Date(requestTimestamp + toTimeWithdrawal).toISOString(),