From fcd93fe25b88a08e93151c81b557671b8e043475 Mon Sep 17 00:00:00 2001 From: lserra-iov Date: Mon, 15 Apr 2024 13:02:33 -0300 Subject: [PATCH] Rename flyover service --- src/__tests__/unit/register.controller.unit.ts | 10 +++++----- src/__tests__/unit/tx-status.controller.unit.ts | 6 +++--- src/controllers/register.controller.ts | 8 ++++---- src/controllers/tx-status.controller.ts | 8 ++++---- src/dependency-injection-bindings.ts | 2 +- ...{register-flyover.service.ts => flyover.service.ts} | 4 ++-- src/services/index.ts | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) rename src/services/{register-flyover.service.ts => flyover.service.ts} (94%) diff --git a/src/__tests__/unit/register.controller.unit.ts b/src/__tests__/unit/register.controller.unit.ts index 35e0f56b..860f01ce 100644 --- a/src/__tests__/unit/register.controller.unit.ts +++ b/src/__tests__/unit/register.controller.unit.ts @@ -4,12 +4,12 @@ import {RegisterService} from '../../services/register.service'; import {RegisterPayload} from '../../models'; import {SessionRepository} from '../../repositories'; import * as constants from '../../constants'; -import {RegisterFlyoverService} from '../../services'; +import {FlyoverService} from '../../services'; describe('RegisterController', () => { let registerController: RegisterController; let registerService: RegisterService; - let registerFlyoverService: RegisterFlyoverService; + let flyoverService: FlyoverService; let sessionRepository: StubbedInstanceWithSinonAccessor; let context: ExpressContextStub; let register: sinon.SinonStub; @@ -47,14 +47,14 @@ describe('RegisterController', () => { function reset() { context = stubExpressContext(); registerService = createStubInstance(RegisterService); - registerFlyoverService = createStubInstance(RegisterFlyoverService); + flyoverService = createStubInstance(FlyoverService); sessionRepository = createStubInstance(SessionRepository); get = sessionRepository.get as sinon.SinonStub; register = registerService.register as sinon.SinonStub; - registerFlyover = registerFlyoverService.register as sinon.SinonStub; + registerFlyover = flyoverService.register as sinon.SinonStub; registerController = new RegisterController( registerService, - registerFlyoverService, + flyoverService, context.response, sessionRepository, ); diff --git a/src/__tests__/unit/tx-status.controller.unit.ts b/src/__tests__/unit/tx-status.controller.unit.ts index 40043a24..ecd138c3 100644 --- a/src/__tests__/unit/tx-status.controller.unit.ts +++ b/src/__tests__/unit/tx-status.controller.unit.ts @@ -1,5 +1,5 @@ import {TxStatusController} from "../../controllers"; -import {PeginStatusService, PegoutStatusService, RegisterFlyoverService} from "../../services"; +import {PeginStatusService, PegoutStatusService, FlyoverService} from "../../services"; import {createStubInstance, expect, StubbedInstanceWithSinonAccessor} from "@loopback/testlab"; import {BtcPeginStatus, PeginStatus, RskPeginStatus, Status, TxStatus, TxStatusType} from "../../models"; import {PeginStatus as RskPeginStatusEnum} from "../../models/rsk/pegin-status-data.model"; @@ -18,12 +18,12 @@ describe('Controller: Tx Status', () => { let txStatusController: TxStatusController; let peginStatusService: StubbedInstanceWithSinonAccessor; let pegoutStatusService: StubbedInstanceWithSinonAccessor; - let flyoverService: StubbedInstanceWithSinonAccessor; + let flyoverService: StubbedInstanceWithSinonAccessor; function resetController() { peginStatusService = createStubInstance(PeginStatusService); pegoutStatusService = createStubInstance(PegoutStatusService); - flyoverService = createStubInstance(RegisterFlyoverService); + flyoverService = createStubInstance(FlyoverService); txStatusController = new TxStatusController(peginStatusService, pegoutStatusService, flyoverService); } function getMockedPeginStatus(mockedTxId: string,status: Status): PeginStatus { diff --git a/src/controllers/register.controller.ts b/src/controllers/register.controller.ts index a4067eee..5dec1a3f 100644 --- a/src/controllers/register.controller.ts +++ b/src/controllers/register.controller.ts @@ -4,7 +4,7 @@ import {Response, RestBindings, getModelSchemaRef, post, requestBody} from '@loo import {repository} from '@loopback/repository'; import {ServicesBindings} from '../dependency-injection-bindings'; import {RegisterPayload} from '../models'; -import {RegisterService, RegisterFlyoverService} from '../services'; +import {RegisterService, FlyoverService} from '../services'; import {SessionRepository} from '../repositories'; import * as constants from '../constants'; @@ -14,8 +14,8 @@ export class RegisterController { constructor( @inject(ServicesBindings.REGISTER_SERVICE) protected registerService: RegisterService, - @inject(ServicesBindings.REGISTER_FLYOVER_SERVICE) - protected registerFlyoverService: RegisterFlyoverService, + @inject(ServicesBindings.FLYOVER_SERVICE) + protected flyoverService: FlyoverService, @inject(RestBindings.Http.RESPONSE) private response: Response, @repository(SessionRepository) @@ -47,7 +47,7 @@ export class RegisterController { await this.registerService.register(payload); } if (provider) { - await this.registerFlyoverService.register(payload); + await this.flyoverService.register(payload); } return this.response.status(200).send(); } diff --git a/src/controllers/tx-status.controller.ts b/src/controllers/tx-status.controller.ts index 94c42e54..fe45b92f 100644 --- a/src/controllers/tx-status.controller.ts +++ b/src/controllers/tx-status.controller.ts @@ -4,7 +4,7 @@ import {inject} from "@loopback/core"; import {PeginStatus, Status, TxStatus, TxStatusType} from '../models'; import {PeginStatusError} from "../models/pegin-status-error.model"; import {ServicesBindings} from "../dependency-injection-bindings"; -import {PeginStatusService, PegoutStatusService, RegisterFlyoverService} from "../services"; +import {PeginStatusService, PegoutStatusService, FlyoverService} from "../services"; import {PegoutStatus} from "../models/rsk/pegout-status-data-model"; import {ensure0x, remove0x} from '../utils/hex-utils'; import {isValidTxId} from '../utils/tx-validator'; @@ -19,8 +19,8 @@ export class TxStatusController { protected peginStatusService: PeginStatusService, @inject(ServicesBindings.PEGOUT_STATUS_SERVICE) protected pegoutStatusService: PegoutStatusService, - @inject(ServicesBindings.REGISTER_FLYOVER_SERVICE) - protected registerFlyoverService: RegisterFlyoverService, + @inject(ServicesBindings.FLYOVER_SERVICE) + protected flyoverService: FlyoverService, ) { this.logger = getLogger('TxStatusController'); } @@ -89,7 +89,7 @@ export class TxStatusController { try { this.logger.debug(`[getTxStatus] trying to get a flyover status with txHash: ${txId}`); - const flyoverStatus = await this.registerFlyoverService.getFlyoverStatus(txId); + const flyoverStatus = await this.flyoverService.getFlyoverStatus(txId); if (flyoverStatus) { this.logger.debug(`[getTxStatus] Flyover status got for txId ${txId} - Status: ${flyoverStatus.status}`); if (flyoverStatus.type === TX_TYPE_PEGIN) { diff --git a/src/dependency-injection-bindings.ts b/src/dependency-injection-bindings.ts index 5f063955..fecac51b 100644 --- a/src/dependency-injection-bindings.ts +++ b/src/dependency-injection-bindings.ts @@ -37,5 +37,5 @@ export const ServicesBindings = { UTXO_PROVIDER_SERVICE: 'services.UtxoProvider', REGISTER_SERVICE: 'services.RegisterService', FEATURES_SERVICE: 'services.FeaturesDataService', - REGISTER_FLYOVER_SERVICE: 'services.RegisterFlyoverService', + FLYOVER_SERVICE: 'services.FlyoverService', }; diff --git a/src/services/register-flyover.service.ts b/src/services/flyover.service.ts similarity index 94% rename from src/services/register-flyover.service.ts rename to src/services/flyover.service.ts index 5a1e0a93..6de98ee7 100644 --- a/src/services/register-flyover.service.ts +++ b/src/services/flyover.service.ts @@ -18,12 +18,12 @@ const FlyoverStatusSchema = new mongoose.Schema({ const FlyoverStatusConnector = mongoose.model('FlyoverStatuses', FlyoverStatusSchema); -export class RegisterFlyoverService extends MongoDbDataService { +export class FlyoverService extends MongoDbDataService { rskNodeService = new RskNodeService(); protected getLoggerName(): string { - return 'registerFlyService'; + return 'flyoverService'; } protected getConnector(): mongoose.Model { diff --git a/src/services/index.ts b/src/services/index.ts index c35da0fb..56862ca2 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -14,4 +14,4 @@ export * from './sync-status-data.service'; export * from './rsk-node.service'; export * from './register.service'; export * from './features-data.service'; -export * from './register-flyover.service'; +export * from './flyover.service';