Skip to content

Commit

Permalink
Merge pull request #221 from lidofinance/feature/si-1352-prepare-for-…
Browse files Browse the repository at this point in the history
…opensource

feat: up nodejs version, added status initialization to v1 request ti…
  • Loading branch information
Tarens2 authored May 6, 2024
2 parents 92971c0 + d266b30 commit 50082c2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "20"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run tests
run: yarn test


4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine as building
FROM node:20-alpine as building

WORKDIR /app

Expand All @@ -9,7 +9,7 @@ COPY ./src ./src
RUN yarn install --frozen-lockfile --non-interactive && yarn cache clean
RUN yarn build

FROM node:18-alpine
FROM node:20-alpine

WORKDIR /app

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The service is helpful for stakers, providing insights from the moment of withdr

### Prerequisites

- Node.js (version 16.0 or higher)
- Node.js (version 20.0 or higher)
- Yarn (version 1.22 or higher)

### Installation
Expand Down Expand Up @@ -46,6 +46,7 @@ $ yarn start
$ yarn start:dev

# production mode
$ yarn build
$ yarn start:prod
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"license": "MIT",
"engines": {
"node": ">=16",
"node": ">=20",
"yarn": ">=1.22"
},
"scripts": {
Expand Down
18 changes: 13 additions & 5 deletions src/http/request-time/dto/request-time.dto.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
import { ApiProperty } from '@nestjs/swagger';
import { WaitingTimeStatus } from '../../../waiting-time';

export class RequestTimeDto {
@ApiProperty({
example: 5,
description: 'Maximum waiting days',
})
days: number;
days?: number;

@ApiProperty({
example: 0,
description: 'Queue ETH last update timestamp',
})
stethLastUpdate: number;
stethLastUpdate?: number;

@ApiProperty({
example: 0,
description: 'Validators last update timestamp',
})
validatorsLastUpdate: number;
validatorsLastUpdate?: number;

@ApiProperty({
example: 10,
description: 'Queue requests count',
})
requests: number;
requests?: number;

@ApiProperty({
example: 0,
description: 'Queue steth amount',
})
steth: string;
steth?: string;

@ApiProperty({
type: 'string',
description: 'Status of request calculation',
enum: Object.values(WaitingTimeStatus),
})
status: WaitingTimeStatus;
}
15 changes: 12 additions & 3 deletions src/http/request-time/request-time.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LOGGER_PROVIDER } from '@lido-nestjs/logger';
import { parseEther } from '@ethersproject/units';

import { QueueInfoStorageService, ValidatorsStorageService } from 'storage';
import { WaitingTimeService } from 'waiting-time';
import { WaitingTimeService, WaitingTimeStatus } from 'waiting-time';

import { RequestTimeDto, RequestTimeOptionsDto } from './dto';
import { RequestTimeV2Dto } from './dto/request-time-v2.dto';
Expand All @@ -23,10 +23,18 @@ export class RequestTimeService {

async getRequestTime(params: RequestTimeOptionsDto): Promise<RequestTimeDto | null> {
const validatorsLastUpdate = this.validators.getLastUpdate();
if (!validatorsLastUpdate) return null;
if (!validatorsLastUpdate) {
return {
status: WaitingTimeStatus.initializing,
};
}

const unfinalizedETH = this.queueInfo.getStETH();
if (!unfinalizedETH) return null;
if (!unfinalizedETH) {
return {
status: WaitingTimeStatus.initializing,
};
}

const additionalStETH = parseEther(params.amount || '0');
const queueStETH = unfinalizedETH.add(additionalStETH);
Expand All @@ -47,6 +55,7 @@ export class RequestTimeService {
validatorsLastUpdate,
steth: unfinalizedETH.toString(),
requests: requestsCount.toNumber(),
status: WaitingTimeStatus.calculated,
};
}

Expand Down

0 comments on commit 50082c2

Please sign in to comment.