From f94c1e14e39e44b4a87a1458c64c744e4a6723f7 Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Tue, 12 Aug 2025 12:32:35 +0300 Subject: [PATCH 1/6] refactor: tsconfig --- .../reputation-oracle/server/package.json | 2 +- .../server/src/common/pipes/validation.ts | 2 +- .../typeorm/typeorm-logger.service.ts | 2 +- .../src/modules/abuse/abuse.controller.ts | 2 +- .../src/modules/auth/auth.controller.ts | 2 +- .../results-processing/index.ts | 2 +- .../server/src/modules/kyc/kyc.controller.ts | 2 +- .../server/src/modules/nda/nda.controller.ts | 2 +- .../src/modules/user/user.controller.ts | 2 +- .../reputation-oracle/server/tsconfig.json | 29 ++++++++++++------- yarn.lock | 4 +-- 11 files changed, 30 insertions(+), 21 deletions(-) diff --git a/packages/apps/reputation-oracle/server/package.json b/packages/apps/reputation-oracle/server/package.json index 1007b36f74..0d4a175b1e 100644 --- a/packages/apps/reputation-oracle/server/package.json +++ b/packages/apps/reputation-oracle/server/package.json @@ -94,7 +94,7 @@ "source-map-support": "^0.5.20", "ts-jest": "29.2.5", "ts-node": "^10.9.2", - "tsconfig-paths": "4.2.0", + "tsconfig-paths": "^4.2.0", "type-fest": "^4.37.0", "typescript": "^5.6.3" }, diff --git a/packages/apps/reputation-oracle/server/src/common/pipes/validation.ts b/packages/apps/reputation-oracle/server/src/common/pipes/validation.ts index 1e5a3bfea5..4c1585135a 100644 --- a/packages/apps/reputation-oracle/server/src/common/pipes/validation.ts +++ b/packages/apps/reputation-oracle/server/src/common/pipes/validation.ts @@ -4,7 +4,7 @@ import { Injectable, ValidationError, ValidationPipe, - ValidationPipeOptions, + type ValidationPipeOptions, } from '@nestjs/common'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts b/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts index f6e47ed3b4..e3d982ac92 100644 --- a/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts +++ b/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts @@ -3,7 +3,7 @@ import { Logger as TypeOrmLogger, LoggerOptions as TypeOrmLoggerOptions, } from 'typeorm'; -import { Inject, Injectable, Logger, LoggerService } from '@nestjs/common'; +import { Inject, Injectable, Logger, type LoggerService } from '@nestjs/common'; @Injectable() export class TypeOrmLoggerService implements TypeOrmLogger { diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts index ae1f146530..e1d30657f8 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts @@ -16,7 +16,7 @@ import { } from '@nestjs/swagger'; import { Public } from '../../common/decorators'; -import { RequestWithUser } from '../../common/types'; +import type { RequestWithUser } from '../../common/types'; import { AbuseResponseDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts index 1bac4d8e30..ff4d3db4b2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts @@ -20,7 +20,7 @@ import { } from '@nestjs/common'; import { Public } from '../../common/decorators'; -import { RequestWithUser } from '../../common/types'; +import type { RequestWithUser } from '../../common/types'; import { HCaptchaGuard } from '../../integrations/hcaptcha/hcaptcha.guard'; import { AuthService } from './auth.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/index.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/index.ts index 0083a791b7..3c8da7e4c1 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/index.ts @@ -1,4 +1,4 @@ export { AudinoResultsProcessor } from './audino-results-processor'; export { CvatResultsProcessor } from './cvat-results-processor'; -export { EscrowResultsProcessor } from './escrow-results-processor'; +export { type EscrowResultsProcessor } from './escrow-results-processor'; export { FortuneResultsProcessor } from './fortune-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts index fc6d4e928a..4bf41d618f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts @@ -18,7 +18,7 @@ import { } from '@nestjs/swagger'; import { Public } from '../../common/decorators'; -import { RequestWithUser } from '../../common/types'; +import type { RequestWithUser } from '../../common/types'; import { StartSessionResponseDto, KycSignedAddressDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts index d802f8ea3d..4f8ca6f70f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts @@ -15,7 +15,7 @@ import { ApiTags, } from '@nestjs/swagger'; -import { RequestWithUser } from '../../common/types'; +import type { RequestWithUser } from '../../common/types'; import { NDAConfigService } from '../../config'; import { NDASignatureDto } from './nda.dto'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts index 92daefe48d..de3681708d 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts @@ -19,7 +19,7 @@ import { import { Public } from '../../common/decorators'; import { SignatureType } from '../../common/enums'; -import { RequestWithUser } from '../../common/types'; +import type { RequestWithUser } from '../../common/types'; import { Web3ConfigService } from '../../config'; import { HCaptchaGuard } from '../../integrations/hcaptcha/hcaptcha.guard'; import * as web3Utils from '../../utils/web3'; diff --git a/packages/apps/reputation-oracle/server/tsconfig.json b/packages/apps/reputation-oracle/server/tsconfig.json index 0da4095d9a..b517dc2243 100644 --- a/packages/apps/reputation-oracle/server/tsconfig.json +++ b/packages/apps/reputation-oracle/server/tsconfig.json @@ -1,24 +1,33 @@ { "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, + "module": "node18", + "moduleResolution": "node16", + "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "allowJs": true, - "target": "es2023", "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es2024", + "rootDir": ".", "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": true, + "forceConsistentCasingInFileNames": true, "noImplicitAny": true, "strictBindCallApply": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "esModuleInterop": true , + "isolatedModules": true, + "paths": { + "@/*": ["src/*"], + "~/test/*": ["test/*"] + }, "resolveJsonModule": true + }, + "ts-node": { + "files": true, + "require": [ + "tsconfig-paths/register" + ] } } diff --git a/yarn.lock b/yarn.lock index afc996370e..2cf70057dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4567,7 +4567,7 @@ __metadata: source-map-support: "npm:^0.5.20" ts-jest: "npm:29.2.5" ts-node: "npm:^10.9.2" - tsconfig-paths: "npm:4.2.0" + tsconfig-paths: "npm:^4.2.0" type-fest: "npm:^4.37.0" typeorm: "npm:^0.3.25" typeorm-naming-strategies: "npm:^4.1.0" @@ -28831,7 +28831,7 @@ __metadata: languageName: node linkType: hard -"tsconfig-paths@npm:4.2.0, tsconfig-paths@npm:^4.1.2": +"tsconfig-paths@npm:4.2.0, tsconfig-paths@npm:^4.1.2, tsconfig-paths@npm:^4.2.0": version: 4.2.0 resolution: "tsconfig-paths@npm:4.2.0" dependencies: From 8cfa7d6494aa46d1be8a7af1752f36b785e7c369 Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Tue, 12 Aug 2025 12:34:43 +0300 Subject: [PATCH 2/6] chore: remove excessive module --- packages/apps/reputation-oracle/server/package.json | 1 - packages/apps/reputation-oracle/server/src/app.module.ts | 9 --------- yarn.lock | 3 +-- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/apps/reputation-oracle/server/package.json b/packages/apps/reputation-oracle/server/package.json index 0d4a175b1e..eec767810c 100644 --- a/packages/apps/reputation-oracle/server/package.json +++ b/packages/apps/reputation-oracle/server/package.json @@ -39,7 +39,6 @@ "@nestjs/passport": "^10.0.0", "@nestjs/platform-express": "^10.3.10", "@nestjs/schedule": "^4.0.1", - "@nestjs/serve-static": "^4.0.2", "@nestjs/swagger": "^7.4.2", "@nestjs/terminus": "^11.0.0", "@nestjs/typeorm": "^10.0.1", diff --git a/packages/apps/reputation-oracle/server/src/app.module.ts b/packages/apps/reputation-oracle/server/src/app.module.ts index 87b88ef05d..dbcab17043 100644 --- a/packages/apps/reputation-oracle/server/src/app.module.ts +++ b/packages/apps/reputation-oracle/server/src/app.module.ts @@ -2,8 +2,6 @@ import { ClassSerializerInterceptor, Module } from '@nestjs/common'; import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core'; import { ConfigModule } from '@nestjs/config'; import { ScheduleModule } from '@nestjs/schedule'; -import { ServeStaticModule } from '@nestjs/serve-static'; -import { join } from 'path'; import { AppController } from './app.controller'; import { JwtAuthGuard } from './common/guards'; @@ -62,13 +60,6 @@ import Environment from './utils/environment'; ], imports: [ ScheduleModule.forRoot(), - ServeStaticModule.forRoot({ - rootPath: join( - __dirname, - '../../../../../../', - 'node_modules/swagger-ui-dist', - ), - }), ConfigModule.forRoot({ /** * First value found takes precendece diff --git a/yarn.lock b/yarn.lock index 2cf70057dd..0068e60718 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4522,7 +4522,6 @@ __metadata: "@nestjs/platform-express": "npm:^10.3.10" "@nestjs/schedule": "npm:^4.0.1" "@nestjs/schematics": "npm:^11.0.2" - "@nestjs/serve-static": "npm:^4.0.2" "@nestjs/swagger": "npm:^7.4.2" "@nestjs/terminus": "npm:^11.0.0" "@nestjs/testing": "npm:^10.4.6" @@ -6577,7 +6576,7 @@ __metadata: languageName: node linkType: hard -"@nestjs/serve-static@npm:^4.0.1, @nestjs/serve-static@npm:^4.0.2": +"@nestjs/serve-static@npm:^4.0.1": version: 4.0.2 resolution: "@nestjs/serve-static@npm:4.0.2" dependencies: From 923f9e6fa119a8d7eb735886c5abff68d5c2af99 Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Tue, 12 Aug 2025 13:04:48 +0300 Subject: [PATCH 3/6] refactor: use aliases --- .../server/src/common/decorators/index.ts | 2 +- .../src/common/filters/exception.filter.ts | 6 ++-- .../server/src/common/guards/jwt.auth.ts | 4 +-- .../server/src/common/guards/roles.auth.ts | 2 +- .../src/common/guards/signature.auth.spec.ts | 8 ++--- .../src/common/guards/signature.auth.ts | 4 +-- .../transform.interceptor.spec.ts | 2 +- .../interceptors/transform.interceptor.ts | 2 +- .../server/src/common/types/manifest.ts | 2 +- .../server/src/database/database.module.ts | 33 +++++++++++-------- .../server/src/database/errors.ts | 2 +- .../1752590727473-InitialMigration.ts | 2 +- .../integrations/hcaptcha/fixtures/index.ts | 2 +- .../hcaptcha/hcaptcha.guard.spec.ts | 2 +- .../hcaptcha/hcaptcha.service.spec.ts | 6 ++-- .../integrations/hcaptcha/hcaptcha.service.ts | 4 +-- .../slack-bot-app/slack-bot-app.spec.ts | 2 +- .../slack-bot-app/slack-bot-app.ts | 4 +-- .../server/src/logger/index.ts | 4 +-- .../modules/abuse/abuse-slack-auth.guard.ts | 4 +-- .../src/modules/abuse/abuse-slack-bot.spec.ts | 4 +-- .../src/modules/abuse/abuse-slack-bot.ts | 4 +-- .../src/modules/abuse/abuse.controller.ts | 4 +-- .../server/src/modules/abuse/abuse.dto.ts | 2 +- .../server/src/modules/abuse/abuse.entity.ts | 6 ++-- .../server/src/modules/abuse/abuse.module.ts | 4 +-- .../src/modules/abuse/abuse.repository.ts | 4 +-- .../src/modules/abuse/abuse.service.spec.ts | 13 +++++--- .../server/src/modules/abuse/abuse.service.ts | 13 +++++--- .../src/modules/abuse/fixtures/index.ts | 6 ++-- .../server/src/modules/abuse/index.ts | 1 + .../src/modules/auth/auth.controller.ts | 6 ++-- .../src/modules/auth/auth.error-filter.ts | 2 +- .../server/src/modules/auth/auth.error.ts | 2 +- .../server/src/modules/auth/auth.module.ts | 10 +++--- .../src/modules/auth/auth.service.spec.ts | 22 ++++++------- .../server/src/modules/auth/auth.service.ts | 16 ++++----- .../auth/dto/email-verification.dto.ts | 2 +- .../src/modules/auth/dto/password.dto.ts | 2 +- .../src/modules/auth/dto/sign-in.dto.ts | 5 +-- .../src/modules/auth/dto/sign-up.dto.ts | 4 +-- .../server/src/modules/auth/index.ts | 1 + .../src/modules/auth/jwt-http-strategy.ts | 6 ++-- .../server/src/modules/auth/token.entity.ts | 6 ++-- .../src/modules/auth/token.repository.ts | 2 +- .../src/modules/cron-job/cron-job.entity.ts | 4 +-- .../src/modules/cron-job/cron-job.module.ts | 11 ++++--- .../modules/cron-job/cron-job.repository.ts | 2 +- .../modules/cron-job/cron-job.service.spec.ts | 11 ++++--- .../src/modules/cron-job/cron-job.service.ts | 15 +++++---- .../server/src/modules/cron-job/index.ts | 1 + .../modules/email/sendgrid.service.spec.ts | 8 ++--- .../src/modules/email/sendgrid.service.ts | 6 ++-- .../modules/encryption/encryption.module.ts | 2 +- .../encryption/pgp-encryption.service.spec.ts | 6 ++-- .../encryption/pgp-encryption.service.ts | 6 ++-- .../escrow-completion.entity.ts | 4 +-- .../escrow-completion.module.ts | 8 ++--- .../escrow-completion.repository.ts | 4 +-- .../escrow-completion.service.spec.ts | 16 ++++----- .../escrow-completion.service.ts | 28 ++++++++-------- .../escrow-payouts-batch.entity.ts | 4 +-- .../escrow-payouts-batch.repository.ts | 2 +- .../escrow-completion/fixtures/cvat.ts | 4 +-- .../fixtures/escrow-completion.ts | 2 +- .../escrow-completion/fixtures/fortune.ts | 4 +-- .../src/modules/escrow-completion/index.ts | 2 ++ .../audino-payouts-calculator.ts | 8 ++--- .../cvat-payouts-calculator.spec.ts | 8 ++--- .../cvat-payouts-calculator.ts | 8 ++--- .../fortune-payouts-calculator.spec.ts | 2 +- .../fortune-payouts-calculator.ts | 4 +-- .../payouts-calculation/module.ts | 4 +-- .../payouts-calculation/types.ts | 2 +- .../audino-results-processor.ts | 4 +-- .../cvat-results-processor.spec.ts | 6 ++-- .../cvat-results-processor.ts | 4 +-- .../escrow-results-processor.spec.ts | 8 ++--- .../escrow-results-processor.ts | 10 +++--- .../fortune-results-processor.spec.ts | 8 ++--- .../fortune-results-processor.ts | 2 +- .../results-processing/module.ts | 6 ++-- .../modules/health/health.controller.spec.ts | 4 +-- .../src/modules/health/health.controller.ts | 6 ++-- .../server/src/modules/kyc/fixtures/index.ts | 2 +- .../server/src/modules/kyc/index.ts | 2 ++ .../src/modules/kyc/kyc-webhook-auth.guard.ts | 2 +- .../server/src/modules/kyc/kyc.controller.ts | 4 +-- .../server/src/modules/kyc/kyc.entity.ts | 6 ++-- .../src/modules/kyc/kyc.error-filter.ts | 2 +- .../server/src/modules/kyc/kyc.error.ts | 2 +- .../server/src/modules/kyc/kyc.module.ts | 4 +-- .../server/src/modules/kyc/kyc.repository.ts | 2 +- .../src/modules/kyc/kyc.service.spec.ts | 16 ++++----- .../server/src/modules/kyc/kyc.service.ts | 10 +++--- .../server/src/modules/nda/fixtures/index.ts | 2 +- .../server/src/modules/nda/nda.controller.ts | 4 +-- .../src/modules/nda/nda.error-filter.ts | 2 +- .../server/src/modules/nda/nda.error.ts | 2 +- .../server/src/modules/nda/nda.module.ts | 2 +- .../src/modules/nda/nda.service.spec.ts | 6 ++-- .../server/src/modules/nda/nda.service.ts | 4 +-- .../server/src/modules/qualification/index.ts | 2 ++ .../qualification/qualification.controller.ts | 6 ++-- .../qualification/qualification.entity.ts | 4 +-- .../qualification.error-filter.ts | 2 +- .../qualification/qualification.error.ts | 2 +- .../qualification/qualification.module.ts | 2 +- .../qualification/qualification.repository.ts | 2 +- .../qualification.service.spec.ts | 10 +++--- .../qualification/qualification.service.ts | 6 ++-- .../user-qualification.entity.ts | 8 ++--- .../user-qualification.repository.ts | 2 +- .../src/modules/reputation/fixtures/index.ts | 2 +- .../server/src/modules/reputation/index.ts | 1 + .../reputation/reputation.controller.ts | 4 +-- .../src/modules/reputation/reputation.dto.ts | 4 +-- .../modules/reputation/reputation.entity.ts | 4 +-- .../modules/reputation/reputation.module.ts | 2 +- .../reputation/reputation.repository.ts | 4 +-- .../reputation/reputation.service.spec.ts | 6 ++-- .../modules/reputation/reputation.service.ts | 8 ++--- .../src/modules/storage/storage.module.ts | 2 +- .../modules/storage/storage.service.spec.ts | 8 ++--- .../src/modules/storage/storage.service.ts | 10 +++--- .../src/modules/user/fixtures/sitekey.ts | 2 +- .../server/src/modules/user/fixtures/user.ts | 6 ++-- .../server/src/modules/user/index.ts | 2 +- .../src/modules/user/site-key.entity.ts | 4 +-- .../src/modules/user/site-key.repository.ts | 2 +- .../src/modules/user/user.controller.ts | 12 +++---- .../server/src/modules/user/user.dto.ts | 7 ++-- .../server/src/modules/user/user.entity.ts | 8 ++--- .../src/modules/user/user.error-filter.ts | 2 +- .../server/src/modules/user/user.error.ts | 2 +- .../server/src/modules/user/user.module.ts | 4 +-- .../src/modules/user/user.repository.ts | 2 +- .../src/modules/user/user.service.spec.ts | 18 +++++----- .../server/src/modules/user/user.service.ts | 12 +++---- .../server/src/modules/web3/fixtures/index.ts | 7 ++-- .../src/modules/web3/web3.service.spec.ts | 2 +- .../server/src/modules/web3/web3.service.ts | 2 +- .../src/modules/webhook/fixtures/index.ts | 2 +- .../server/src/modules/webhook/index.ts | 2 ++ .../webhook/webhook-incoming.entity.ts | 4 +-- .../webhook/webhook-incoming.module.ts | 2 +- .../webhook/webhook-incoming.repository.ts | 4 +-- .../webhook/webhook-incoming.service.spec.ts | 8 ++--- .../webhook/webhook-incoming.service.ts | 12 +++---- .../webhook/webhook-outgoing.entity.ts | 4 +-- .../webhook/webhook-outgoing.module.ts | 2 +- .../webhook/webhook-outgoing.repository.ts | 4 +-- .../webhook/webhook-outgoing.service.spec.ts | 12 +++---- .../webhook/webhook-outgoing.service.ts | 14 ++++---- .../src/modules/webhook/webhook.controller.ts | 6 ++-- .../server/src/modules/webhook/webhook.dto.ts | 2 +- .../server/src/utils/backoff.ts | 2 +- .../server/src/utils/http.ts | 2 +- .../server/src/utils/manifest.ts | 4 +-- .../server/src/utils/web3.spec.ts | 2 +- 160 files changed, 436 insertions(+), 409 deletions(-) diff --git a/packages/apps/reputation-oracle/server/src/common/decorators/index.ts b/packages/apps/reputation-oracle/server/src/common/decorators/index.ts index 6657877613..1928a9fc7e 100644 --- a/packages/apps/reputation-oracle/server/src/common/decorators/index.ts +++ b/packages/apps/reputation-oracle/server/src/common/decorators/index.ts @@ -1,5 +1,5 @@ import { Reflector } from '@nestjs/core'; -import { UserRole } from '../../modules/user'; +import { UserRole } from '@/modules/user'; /** * Decorator for HTTP endpoints to bypass JWT auth guard diff --git a/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts b/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts index 3b5e94fc68..41ddd25626 100644 --- a/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts +++ b/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts @@ -6,9 +6,9 @@ import { HttpException, } from '@nestjs/common'; import { Request, Response } from 'express'; -import { DatabaseError, isDuplicatedError } from '../../database'; -import logger from '../../logger'; -import { transformKeysFromCamelToSnake } from '../../utils/case-converters'; +import { DatabaseError, isDuplicatedError } from '@/database'; +import logger from '@/logger'; +import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; @Catch() export class ExceptionFilter implements IExceptionFilter { diff --git a/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts index 149abc48e7..9b47ceb74e 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts @@ -6,8 +6,8 @@ import { } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { AuthGuard } from '@nestjs/passport'; -import { JWT_STRATEGY_NAME } from '../constants'; -import { Public } from '../decorators'; +import { JWT_STRATEGY_NAME } from '@/common/constants'; +import { Public } from '@/common/decorators'; @Injectable() export class JwtAuthGuard extends AuthGuard(JWT_STRATEGY_NAME) { diff --git a/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts index ac4373eb82..50f12e1f27 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts @@ -6,7 +6,7 @@ import { HttpException, } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import { Roles } from '../decorators'; +import { Roles } from '@/common/decorators'; @Injectable() export class RolesAuthGuard implements CanActivate { diff --git a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts index d437e9cff8..56803f8a5a 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts @@ -4,13 +4,13 @@ import { faker } from '@faker-js/faker'; import { EscrowUtils } from '@human-protocol/sdk'; import { ExecutionContext, HttpException, HttpStatus } from '@nestjs/common'; -import { generateEthWallet } from '../../../test/fixtures/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { createExecutionContextMock, ExecutionContextMock, -} from '../../../test/mock-creators/nest'; -import { generateTestnetChainId } from '../../modules/web3/fixtures'; -import { signMessage } from '../../utils/web3'; +} from '~/test/mock-creators/nest'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { signMessage } from '@/utils/web3'; import { AuthSignatureRole, SignatureAuthGuard } from './signature.auth'; diff --git a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts index cace3f0788..fbf919de90 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts @@ -6,8 +6,8 @@ import { HttpStatus, Injectable, } from '@nestjs/common'; -import { verifySignature } from '../../utils/web3'; -import { HEADER_SIGNATURE_KEY } from '../constants'; +import { verifySignature } from '@/utils/web3'; +import { HEADER_SIGNATURE_KEY } from '@/common/constants'; export enum AuthSignatureRole { JOB_LAUNCHER = 'job_launcher', diff --git a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts index 7c111923b6..7f452661d2 100644 --- a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts @@ -7,7 +7,7 @@ import { createCallHandlerMock, createExecutionContextMock, ExecutionContextMock, -} from '../../../test/mock-creators/nest'; +} from '~/test/mock-creators/nest'; describe('TransformInterceptor', () => { describe('intercept', () => { diff --git a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts index 49c8070a7e..ceac84ea1b 100644 --- a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts +++ b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts @@ -7,7 +7,7 @@ import { } from '@nestjs/common'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import * as CaseConverter from '../../utils/case-converters'; +import * as CaseConverter from '@/utils/case-converters'; @Injectable() export class TransformInterceptor implements NestInterceptor { diff --git a/packages/apps/reputation-oracle/server/src/common/types/manifest.ts b/packages/apps/reputation-oracle/server/src/common/types/manifest.ts index bcc7d3964e..4685d64d16 100644 --- a/packages/apps/reputation-oracle/server/src/common/types/manifest.ts +++ b/packages/apps/reputation-oracle/server/src/common/types/manifest.ts @@ -1,4 +1,4 @@ -import { AudinoJobType, CvatJobType, FortuneJobType } from '../enums'; +import { AudinoJobType, CvatJobType, FortuneJobType } from '@/common/enums'; export type FortuneManifest = { submissionsRequired: number; diff --git a/packages/apps/reputation-oracle/server/src/database/database.module.ts b/packages/apps/reputation-oracle/server/src/database/database.module.ts index 52f41561e9..ee4719f1ec 100644 --- a/packages/apps/reputation-oracle/server/src/database/database.module.ts +++ b/packages/apps/reputation-oracle/server/src/database/database.module.ts @@ -3,20 +3,25 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { LoggerOptions } from 'typeorm'; import { SnakeNamingStrategy } from 'typeorm-naming-strategies'; -import { ReputationEntity } from '../modules/reputation/reputation.entity'; -import { TokenEntity } from '../modules/auth/token.entity'; -import { UserEntity } from '../modules/user/user.entity'; -import { KycEntity } from '../modules/kyc/kyc.entity'; -import { CronJobEntity } from '../modules/cron-job/cron-job.entity'; -import { DatabaseConfigService } from '../config'; -import { SiteKeyEntity } from '../modules/user/site-key.entity'; -import { QualificationEntity } from '../modules/qualification/qualification.entity'; -import { UserQualificationEntity } from '../modules/qualification/user-qualification.entity'; -import { IncomingWebhookEntity } from '../modules/webhook/webhook-incoming.entity'; -import { OutgoingWebhookEntity } from '../modules/webhook/webhook-outgoing.entity'; -import { EscrowCompletionEntity } from '../modules/escrow-completion/escrow-completion.entity'; -import { EscrowPayoutsBatchEntity } from '../modules/escrow-completion/escrow-payouts-batch.entity'; -import { AbuseEntity } from '../modules/abuse/abuse.entity'; +import { DatabaseConfigService } from '@/config'; +import { ReputationEntity } from '@/modules/reputation'; +import { TokenEntity } from '@/modules/auth'; +import { UserEntity, SiteKeyEntity } from '@/modules/user'; +import { KycEntity } from '@/modules/kyc'; +import { CronJobEntity } from '@/modules/cron-job'; +import { + QualificationEntity, + UserQualificationEntity, +} from '@/modules/qualification'; +import { + IncomingWebhookEntity, + OutgoingWebhookEntity, +} from '@/modules/webhook'; +import { + EscrowCompletionEntity, + EscrowPayoutsBatchEntity, +} from '@/modules/escrow-completion'; +import { AbuseEntity } from '@/modules/abuse'; import { TypeOrmLoggerModule, TypeOrmLoggerService } from './typeorm'; diff --git a/packages/apps/reputation-oracle/server/src/database/errors.ts b/packages/apps/reputation-oracle/server/src/database/errors.ts index 74d06da4fb..e0f5229260 100644 --- a/packages/apps/reputation-oracle/server/src/database/errors.ts +++ b/packages/apps/reputation-oracle/server/src/database/errors.ts @@ -1,4 +1,4 @@ -import { BaseError } from '../common/errors/base'; +import { BaseError } from '@/common/errors/base'; enum PostgresErrorCodes { Duplicated = '23505', diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts index f38cfa461f..d7bf6716b8 100644 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts +++ b/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; export class InitialMigration1752590727473 implements MigrationInterface { name = 'InitialMigration1752590727473'; diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts index d187210da1..20d94715ed 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts @@ -1,5 +1,5 @@ import { faker } from '@faker-js/faker'; -import { HCaptchaConfigService } from '../../../config'; +import { HCaptchaConfigService } from '@/config'; export const mockHCaptchaConfigService: Omit< HCaptchaConfigService, diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.spec.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.spec.ts index 4ed04ef52d..743f9d4537 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.spec.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.spec.ts @@ -4,7 +4,7 @@ import { ExecutionContext, HttpException, HttpStatus } from '@nestjs/common'; import { createExecutionContextMock, ExecutionContextMock, -} from '../../../test/mock-creators/nest'; +} from '~/test/mock-creators/nest'; import { HCaptchaGuard } from './hcaptcha.guard'; import { HCaptchaService } from './hcaptcha.service'; diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts index 3e9ed38688..0024970326 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts @@ -4,14 +4,14 @@ import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; import { HCaptchaService } from './hcaptcha.service'; -import { HCaptchaConfigService } from '../../config'; +import { HCaptchaConfigService } from '@/config'; import { createHttpServiceMock, createHttpServiceRequestError, createHttpServiceResponse, -} from '../../../test/mock-creators/nest'; -import { generateEthWallet } from '../../../test/fixtures/web3'; +} from '~/test/mock-creators/nest'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { mockHCaptchaConfigService } from './fixtures'; import { LabelerData, SiteverifyResponse } from './types'; diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.ts index 4643db340c..8478882037 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.ts @@ -3,8 +3,8 @@ import { Injectable } from '@nestjs/common'; import { ethers } from 'ethers'; import { firstValueFrom } from 'rxjs'; -import { HCaptchaConfigService } from '../../config'; -import logger from '../../logger'; +import { HCaptchaConfigService } from '@/config'; +import logger from '@/logger'; import { GetLabelerQueryParams, diff --git a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts index 39eaf3e24b..d03afc2179 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts @@ -5,7 +5,7 @@ import { createHttpServiceMock, createHttpServiceRequestError, createHttpServiceResponse, -} from '../../../test/mock-creators/nest'; +} from '~/test/mock-creators/nest'; const mockHttpService = createHttpServiceMock(); diff --git a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts index 39b92d3039..c38296f87e 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts @@ -2,8 +2,8 @@ import { HttpService } from '@nestjs/axios'; import { View, ViewsOpenResponse } from '@slack/web-api'; import { IncomingWebhookSendArguments } from '@slack/webhook'; import { firstValueFrom } from 'rxjs'; -import logger from '../../logger'; -import * as httpUtils from '../../utils/http'; +import logger from '@/logger'; +import * as httpUtils from '@/utils/http'; export class SlackBotApp { private readonly logger = logger.child({ context: SlackBotApp.name }); diff --git a/packages/apps/reputation-oracle/server/src/logger/index.ts b/packages/apps/reputation-oracle/server/src/logger/index.ts index fe8e9df382..fec3e67176 100644 --- a/packages/apps/reputation-oracle/server/src/logger/index.ts +++ b/packages/apps/reputation-oracle/server/src/logger/index.ts @@ -1,7 +1,7 @@ import { createLogger, NestLogger, LogLevel } from '@human-protocol/logger'; -import { SERVICE_NAME } from '../common/constants'; -import Environment from '../utils/environment'; +import { SERVICE_NAME } from '@/common/constants'; +import Environment from '@/utils/environment'; const isDevelopment = Environment.isDevelopment(); diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-auth.guard.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-auth.guard.ts index 0aef547d51..27c8138ecd 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-auth.guard.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-auth.guard.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { SlackAuthGuard } from '../../common/guards/slack.auth'; -import { SlackConfigService } from '../../config/slack-config.service'; +import { SlackAuthGuard } from '@/common/guards/slack.auth'; +import { SlackConfigService } from '@/config'; @Injectable() export class AbuseSlackAuthGuard extends SlackAuthGuard { diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts index 2c44b30887..b9762aeced 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts @@ -2,8 +2,8 @@ import { faker } from '@faker-js/faker'; import { Test } from '@nestjs/testing'; import { HttpService } from '@nestjs/axios'; -import { createHttpServiceMock } from '../../../test/mock-creators/nest'; -import { SlackConfigService } from '../../config'; +import { createHttpServiceMock } from '~/test/mock-creators/nest'; +import { SlackConfigService } from '@/config'; import { AbuseSlackBot } from './abuse-slack-bot'; import { AbuseDecision } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts index 95dba0f892..041663c78a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts @@ -4,8 +4,8 @@ import { Injectable } from '@nestjs/common'; import { View } from '@slack/web-api'; import { IncomingWebhookSendArguments } from '@slack/webhook'; -import { SlackConfigService } from '../../config'; -import { SlackBotApp } from '../../integrations/slack-bot-app'; +import { SlackConfigService } from '@/config'; +import { SlackBotApp } from '@/integrations/slack-bot-app'; import { AbuseDecision } from './constants'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts index e1d30657f8..bdba6d269a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts @@ -15,8 +15,8 @@ import { ApiTags, } from '@nestjs/swagger'; -import { Public } from '../../common/decorators'; -import type { RequestWithUser } from '../../common/types'; +import { Public } from '@/common/decorators'; +import type { RequestWithUser } from '@/common/types'; import { AbuseResponseDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts index 55afd67b15..b5b1337db8 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts @@ -2,7 +2,7 @@ import { ChainId } from '@human-protocol/sdk'; import { ApiProperty } from '@nestjs/swagger'; import { IsEthereumAddress, IsString, MaxLength } from 'class-validator'; -import { IsChainId } from '../../common/validators'; +import { IsChainId } from '@/common/validators'; import { AbuseStatus } from './constants'; export class ReportAbuseDto { diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts index 2f436a1afb..7b7c7f974e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts @@ -1,9 +1,9 @@ import { ChainId } from '@human-protocol/sdk'; import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; -import type { UserEntity } from '../user'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; +import type { UserEntity } from '@/modules/user'; import { AbuseDecision, AbuseStatus } from './constants'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'abuses' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts index 2dc3548c94..f0c6c7e2da 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; -import { Web3Module } from '../web3'; -import { OutgoingWebhookModule } from '../webhook'; +import { Web3Module } from '@/modules/web3'; +import { OutgoingWebhookModule } from '@/modules/webhook'; import { AbuseSlackAuthGuard } from './abuse-slack-auth.guard'; import { AbuseSlackBot } from './abuse-slack-bot'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts index b19a4800d3..38eb73571f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts @@ -7,8 +7,8 @@ import { Not, } from 'typeorm'; -import { ServerConfigService } from '../../config'; -import { BaseRepository } from '../../database'; +import { ServerConfigService } from '@/config'; +import { BaseRepository } from '@/database'; import { AbuseEntity } from './abuse.entity'; import { AbuseStatus } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts index 90c31e8dcb..bc33725cfe 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts @@ -10,11 +10,14 @@ import { } from '@human-protocol/sdk'; import { ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; -import { DatabaseError, DatabaseErrorMessages } from '../../database'; -import { ServerConfigService } from '../../config'; -import { generateTestnetChainId } from '../web3/fixtures'; -import { Web3Service } from '../web3'; -import { OutgoingWebhookEventType, OutgoingWebhookService } from '../webhook'; +import { DatabaseError, DatabaseErrorMessages } from '@/database'; +import { ServerConfigService } from '@/config'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; +import { + OutgoingWebhookEventType, + OutgoingWebhookService, +} from '@/modules/webhook'; import { AbuseRepository } from './abuse.repository'; import { AbuseService } from './abuse.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts index 38d1d206c5..73143a3bf9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts @@ -6,11 +6,14 @@ import { } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { ethers } from 'ethers'; -import { isDuplicatedError } from '../../database'; -import { ServerConfigService } from '../../config'; -import logger from '../../logger'; -import { Web3Service } from '../web3'; -import { OutgoingWebhookEventType, OutgoingWebhookService } from '../webhook'; +import { isDuplicatedError } from '@/database'; +import { ServerConfigService } from '@/config'; +import logger from '@/logger'; +import { Web3Service } from '@/modules/web3'; +import { + OutgoingWebhookEventType, + OutgoingWebhookService, +} from '@/modules/webhook'; import { AbuseEntity } from './abuse.entity'; import { AbuseRepository } from './abuse.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts index c75c6a8826..1807919893 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts @@ -1,7 +1,9 @@ import { faker } from '@faker-js/faker'; -import { generateTestnetChainId } from '../../web3/fixtures'; + +import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { generateWorkerUser } from '@/modules/user/fixtures'; + import { AbuseStatus } from '../constants'; -import { generateWorkerUser } from '../../user/fixtures'; import { AbuseEntity } from '../abuse.entity'; export function generateAbuseEntity( diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/index.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/index.ts index 16abf3f982..fea2b553c9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/index.ts @@ -1,2 +1,3 @@ export { AbuseService } from './abuse.service'; export { AbuseModule } from './abuse.module'; +export { AbuseEntity } from './abuse.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts index ff4d3db4b2..04e27ac2fc 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts @@ -19,9 +19,9 @@ import { Headers, } from '@nestjs/common'; -import { Public } from '../../common/decorators'; -import type { RequestWithUser } from '../../common/types'; -import { HCaptchaGuard } from '../../integrations/hcaptcha/hcaptcha.guard'; +import { Public } from '@/common/decorators'; +import type { RequestWithUser } from '@/common/types'; +import { HCaptchaGuard } from '@/integrations/hcaptcha/hcaptcha.guard'; import { AuthService } from './auth.service'; import { AuthControllerErrorsFilter } from './auth.error-filter'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.error-filter.ts index 4b431061b0..a08a741c97 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.error-filter.ts @@ -6,7 +6,7 @@ import { } from '@nestjs/common'; import { Request, Response } from 'express'; -import logger from '../../logger'; +import logger from '@/logger'; import { AuthError, diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.error.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.error.ts index b50e209ecd..29f9ac3618 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.error.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.error.ts @@ -1,4 +1,4 @@ -import { BaseError } from '../../common/errors/base'; +import { BaseError } from '@/common/errors/base'; export enum AuthErrorMessage { INVALID_CREDENTIALS = 'Invalid email or password', diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.module.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.module.ts index 4780b784c1..f613211882 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.module.ts @@ -1,11 +1,11 @@ import { Module } from '@nestjs/common'; import { JwtModule } from '@nestjs/jwt'; -import { AuthConfigService } from '../../config'; -import { HCaptchaModule } from '../../integrations/hcaptcha'; -import { EmailModule } from '../email'; -import { UserModule } from '../user'; -import { Web3Module } from '../web3'; +import { AuthConfigService } from '@/config'; +import { HCaptchaModule } from '@/integrations/hcaptcha'; +import { EmailModule } from '@/modules/email'; +import { UserModule } from '@/modules/user'; +import { Web3Module } from '@/modules/web3'; import { AuthController } from './auth.controller'; import { AuthService } from './auth.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts index 91852d8c61..3e63e430bc 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts @@ -7,28 +7,28 @@ import { JwtModule, JwtService } from '@nestjs/jwt'; import { Test } from '@nestjs/testing'; import { omit } from 'lodash'; -import { generateES256Keys } from '../../../test/fixtures/crypto'; -import { generateEthWallet } from '../../../test/fixtures/web3'; -import { SignatureType } from '../../common/enums'; +import { generateES256Keys } from '~/test/fixtures/crypto'; +import { generateEthWallet } from '~/test/fixtures/web3'; +import { SignatureType } from '@/common/enums'; import { AuthConfigService, NDAConfigService, ServerConfigService, Web3ConfigService, -} from '../../config'; -import * as secutiryUtils from '../../utils/security'; -import { SiteKeyRepository } from '../user'; -import * as web3Utils from '../../utils/web3'; -import { EmailAction, EmailService } from '../email'; +} from '@/config'; +import * as secutiryUtils from '@/utils/security'; +import { SiteKeyRepository } from '@/modules/user'; +import * as web3Utils from '@/utils/web3'; +import { EmailAction, EmailService } from '@/modules/email'; import { UserStatus, UserRole, UserEntity, UserRepository, UserService, -} from '../user'; -import { generateOperator, generateWorkerUser } from '../user/fixtures'; -import { mockWeb3ConfigService } from '../web3/fixtures'; +} from '@/modules/user'; +import { generateOperator, generateWorkerUser } from '@/modules/user/fixtures'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; import * as AuthErrors from './auth.error'; import { AuthService } from './auth.service'; import { TokenEntity, TokenType } from './token.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts index 0dad0671a0..20bafde940 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts @@ -2,19 +2,19 @@ import { KVStoreKeys, KVStoreUtils, Role } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; -import { SignatureType } from '../../common/enums'; +import { SignatureType } from '@/common/enums'; import { AuthConfigService, NDAConfigService, ServerConfigService, Web3ConfigService, -} from '../../config'; -import logger from '../../logger'; -import * as httpUtils from '../../utils/http'; -import * as securityUtils from '../../utils/security'; -import * as web3Utils from '../../utils/web3'; +} from '@/config'; +import logger from '@/logger'; +import * as httpUtils from '@/utils/http'; +import * as securityUtils from '@/utils/security'; +import * as web3Utils from '@/utils/web3'; -import { EmailAction, EmailService } from '../email'; +import { EmailAction, EmailService } from '@/modules/email'; import { OperatorStatus, SiteKeyRepository, @@ -26,7 +26,7 @@ import { UserStatus, type OperatorUserEntity, type Web2UserEntity, -} from '../user'; +} from '@/modules/user'; import { AuthError, diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/dto/email-verification.dto.ts b/packages/apps/reputation-oracle/server/src/modules/auth/dto/email-verification.dto.ts index b27fc14d02..790dcc0f17 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/dto/email-verification.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/dto/email-verification.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsString, IsUUID } from 'class-validator'; -import { IsLowercasedEmail } from '../../../common/validators'; +import { IsLowercasedEmail } from '@/common/validators'; export class ResendVerificationEmailDto { @ApiProperty() diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/dto/password.dto.ts b/packages/apps/reputation-oracle/server/src/modules/auth/dto/password.dto.ts index edfbabfba3..a1a61c3652 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/dto/password.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/dto/password.dto.ts @@ -2,7 +2,7 @@ import { applyDecorators } from '@nestjs/common'; import { ApiProperty } from '@nestjs/swagger'; import { IsString, MinLength } from 'class-validator'; -import { IsLowercasedEmail } from '../../../common/validators'; +import { IsLowercasedEmail } from '@/common/validators'; export function ValidPassword() { return applyDecorators( diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-in.dto.ts b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-in.dto.ts index 3e1eab400e..feeeddf728 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-in.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-in.dto.ts @@ -1,10 +1,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsEthereumAddress, IsOptional, IsString } from 'class-validator'; -import { - IsLowercasedEmail, - IsValidWeb3Signature, -} from '../../../common/validators'; +import { IsLowercasedEmail, IsValidWeb3Signature } from '@/common/validators'; export class Web2SignInDto { @ApiProperty() diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts index c4c705fb65..0aceb25678 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts @@ -5,8 +5,8 @@ import { IsLowercasedEmail, IsLowercasedEnum, IsValidWeb3Signature, -} from '../../../common/validators'; -import { UserRole } from '../../user'; +} from '@/common/validators'; +import { UserRole } from '@/modules/user'; import { ValidPassword } from './password.dto'; export class Web2SignUpDto { diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/index.ts b/packages/apps/reputation-oracle/server/src/modules/auth/index.ts index 068607f17b..ceb3615eca 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/index.ts @@ -1,2 +1,3 @@ export { AuthModule } from './auth.module'; export { TokenRepository } from './token.repository'; +export { TokenEntity } from './token.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts b/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts index ec0d33f30b..a40f595dfe 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts @@ -6,9 +6,9 @@ import { JWT_STRATEGY_NAME, LOGOUT_PATH, RESEND_EMAIL_VERIFICATION_PATH, -} from '../../common/constants'; -import { UserRole, UserStatus } from '../user'; -import { AuthConfigService } from '../../config'; +} from '@/common/constants'; +import { UserRole, UserStatus } from '@/modules/user'; +import { AuthConfigService } from '@/config'; @Injectable() export class JwtHttpStrategy extends PassportStrategy( diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts b/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts index 261a18d0aa..28cddc786a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts @@ -7,9 +7,9 @@ import { ManyToOne, } from 'typeorm'; -import type { UserEntity } from '../user'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import type { UserEntity } from '@/modules/user'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; export enum TokenType { EMAIL = 'email', diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts b/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts index f5fa8c85da..95fca6ddbd 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, LessThan } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { TokenEntity, TokenType } from './token.entity'; type FindOptions = { diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.entity.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.entity.ts index e23db64fa5..bb610cfae0 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import { CronJobType } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts index 22d8bd274f..d3f5d8c06c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts @@ -1,9 +1,12 @@ import { Module } from '@nestjs/common'; -import { AbuseModule } from '../abuse'; -import { AuthModule } from '../auth'; -import { EscrowCompletionModule } from '../escrow-completion'; -import { IncomingWebhookModule, OutgoingWebhookModule } from '../webhook'; +import { AbuseModule } from '@/modules/abuse'; +import { AuthModule } from '@/modules/auth'; +import { EscrowCompletionModule } from '@/modules/escrow-completion'; +import { + IncomingWebhookModule, + OutgoingWebhookModule, +} from '@/modules/webhook'; import { CronJobService } from './cron-job.service'; import { CronJobRepository } from './cron-job.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.repository.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.repository.ts index e49e90021c..8dd9d09843 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { CronJobType } from './constants'; import { CronJobEntity } from './cron-job.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts index 8ce3e88c17..4787b32913 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts @@ -2,10 +2,13 @@ import { faker } from '@faker-js/faker'; import { createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { AbuseService } from '../abuse'; -import { TokenRepository } from '../auth'; -import { EscrowCompletionService } from '../escrow-completion'; -import { IncomingWebhookService, OutgoingWebhookService } from '../webhook'; +import { AbuseService } from '@/modules/abuse'; +import { TokenRepository } from '@/modules/auth'; +import { EscrowCompletionService } from '@/modules/escrow-completion'; +import { + IncomingWebhookService, + OutgoingWebhookService, +} from '@/modules/webhook'; import { CronJobType } from './constants'; import { CronJobEntity } from './cron-job.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts index 9d4ce0dbd2..3ac4d2cc65 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts @@ -1,12 +1,15 @@ import { Injectable } from '@nestjs/common'; import { Cron } from '@nestjs/schedule'; -import logger from '../../logger'; - -import { AbuseService } from '../abuse'; -import { TokenRepository } from '../auth'; -import { EscrowCompletionService } from '../escrow-completion'; -import { IncomingWebhookService, OutgoingWebhookService } from '../webhook'; +import logger from '@/logger'; + +import { AbuseService } from '@/modules/abuse'; +import { TokenRepository } from '@/modules/auth'; +import { EscrowCompletionService } from '@/modules/escrow-completion'; +import { + IncomingWebhookService, + OutgoingWebhookService, +} from '@/modules/webhook'; import { CronJobType } from './constants'; import { CronJobEntity } from './cron-job.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/index.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/index.ts index 0310bd932c..e860e0a1df 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/index.ts @@ -1 +1,2 @@ export { CronJobModule } from './cron-job.module'; +export { CronJobEntity } from './cron-job.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts index e069287166..ef7e49fecf 100644 --- a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts @@ -1,12 +1,12 @@ -jest.mock('../../logger'); +jest.mock('@/logger'); import { faker } from '@faker-js/faker'; import { Test, TestingModule } from '@nestjs/testing'; import { MailService } from '@sendgrid/mail'; -import { EmailConfigService } from '../../config'; -import logger from '../../logger'; -import Environment from '../../utils/environment'; +import { EmailConfigService } from '@/config'; +import logger from '@/logger'; +import Environment from '@/utils/environment'; import { EmailAction } from './constants'; import { getTemplateId, diff --git a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts index eca415c323..4036e923a1 100644 --- a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@nestjs/common'; import { MailService } from '@sendgrid/mail'; -import { EmailConfigService } from '../../config'; -import logger from '../../logger'; -import Environment from '../../utils/environment'; +import { EmailConfigService } from '@/config'; +import logger from '@/logger'; +import Environment from '@/utils/environment'; import { EmailAction, SENDGRID_API_KEY_REGEX } from './constants'; import { EmailService } from './email.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/encryption/encryption.module.ts b/packages/apps/reputation-oracle/server/src/modules/encryption/encryption.module.ts index c1fbba77cb..623c981886 100644 --- a/packages/apps/reputation-oracle/server/src/modules/encryption/encryption.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/encryption/encryption.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { Web3Module } from '../web3'; +import { Web3Module } from '@/modules/web3'; import { PgpEncryptionService } from './pgp-encryption.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts index c21f363a6b..34e08a08c2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts @@ -14,12 +14,12 @@ import { faker } from '@faker-js/faker'; import { Encryption, EncryptionUtils, KVStoreUtils } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; -import { PGPConfigService, Web3ConfigService } from '../../config'; +import { PGPConfigService, Web3ConfigService } from '@/config'; import { generateTestnetChainId, mockWeb3ConfigService, -} from '../web3/fixtures'; -import { Web3Service } from '../web3'; +} from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; import { PgpEncryptionService } from './pgp-encryption.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts index 03ad18e601..dd22a4e04c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts @@ -6,10 +6,10 @@ import { } from '@human-protocol/sdk'; import { Injectable, OnModuleInit } from '@nestjs/common'; -import { PGPConfigService } from '../../config'; -import logger from '../../logger'; +import { PGPConfigService } from '@/config'; +import logger from '@/logger'; -import { Web3Service } from '../web3'; +import { Web3Service } from '@/modules/web3'; @Injectable() export class PgpEncryptionService implements OnModuleInit { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.entity.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.entity.ts index 04f0c39236..bc27029769 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import { EscrowCompletionStatus } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts index bff3713fbb..fe9eca1ed9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts @@ -1,11 +1,11 @@ import { Module } from '@nestjs/common'; -import { ReputationModule } from '../reputation'; -import { StorageModule } from '../storage'; -import { Web3Module } from '../web3'; +import { ReputationModule } from '@/modules/reputation'; +import { StorageModule } from '@/modules/storage'; +import { Web3Module } from '@/modules/web3'; // Using direct import instead of using index.ts due to the circular dependency -import { OutgoingWebhookModule } from '../webhook/webhook-outgoing.module'; +import { OutgoingWebhookModule } from '@/modules/webhook/webhook-outgoing.module'; import { EscrowCompletionRepository } from './escrow-completion.repository'; import { EscrowCompletionService } from './escrow-completion.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.repository.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.repository.ts index 3e002a88c8..15c94fad97 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.repository.ts @@ -1,8 +1,8 @@ import { Injectable } from '@nestjs/common'; import { DataSource, LessThanOrEqual } from 'typeorm'; -import { ServerConfigService } from '../../config'; -import { BaseRepository } from '../../database'; +import { ServerConfigService } from '@/config'; +import { BaseRepository } from '@/database'; import { EscrowCompletionStatus } from './constants'; import { EscrowCompletionEntity } from './escrow-completion.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts index 7a26a8ab24..dff971ab5e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts @@ -22,16 +22,16 @@ import * as crypto from 'crypto'; import stringify from 'json-stable-stringify'; import _ from 'lodash'; -import { createSignerMock, type SignerMock } from '../../../test/fixtures/web3'; +import { createSignerMock, type SignerMock } from '~/test/fixtures/web3'; -import { CvatJobType, FortuneJobType } from '../../common/enums'; -import { ServerConfigService } from '../../config'; +import { CvatJobType, FortuneJobType } from '@/common/enums'; +import { ServerConfigService } from '@/config'; -import { ReputationService } from '../reputation'; -import { StorageService } from '../storage'; -import { OutgoingWebhookService } from '../webhook'; -import { WalletWithProvider, Web3Service } from '../web3'; -import { generateTestnetChainId } from '../web3/fixtures'; +import { ReputationService } from '@/modules/reputation'; +import { StorageService } from '@/modules/storage'; +import { OutgoingWebhookService } from '@/modules/webhook'; +import { WalletWithProvider, Web3Service } from '@/modules/web3'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { EscrowCompletionStatus } from './constants'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts index af91eb0d7f..bf580a8e21 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts @@ -13,19 +13,21 @@ import { ethers } from 'ethers'; import stringify from 'json-stable-stringify'; import _ from 'lodash'; -import { BACKOFF_INTERVAL_SECONDS } from '../../common/constants'; -import { isDuplicatedError } from '../../database'; -import { JobManifest, JobRequestType } from '../../common/types'; -import { ServerConfigService } from '../../config'; -import logger from '../../logger'; -import { calculateExponentialBackoffMs } from '../../utils/backoff'; -import * as manifestUtils from '../../utils/manifest'; - -import { ReputationService } from '../reputation'; -import { StorageService } from '../storage'; -import { Web3Service } from '../web3'; -import { OutgoingWebhookService } from '../webhook/webhook-outgoing.service'; -import { OutgoingWebhookEventType } from '../webhook/types'; +import { BACKOFF_INTERVAL_SECONDS } from '@/common/constants'; +import { isDuplicatedError } from '@/database'; +import { JobManifest, JobRequestType } from '@/common/types'; +import { ServerConfigService } from '@/config'; +import logger from '@/logger'; +import { calculateExponentialBackoffMs } from '@/utils/backoff'; +import * as manifestUtils from '@/utils/manifest'; + +import { ReputationService } from '@/modules/reputation'; +import { StorageService } from '@/modules/storage'; +import { Web3Service } from '@/modules/web3'; +import { + OutgoingWebhookService, + OutgoingWebhookEventType, +} from '@/modules/webhook'; import { DEFAULT_BULK_PAYOUT_TX_ID, EscrowCompletionStatus } from './constants'; import { EscrowCompletionRepository } from './escrow-completion.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts index 3501f0bc82..cdfe9dcd05 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index, ManyToOne } from 'typeorm'; -import { BaseEntity } from '../../database'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; +import { BaseEntity } from '@/database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import type { EscrowCompletionEntity } from './escrow-completion.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts index 6c30613ff9..9f41ba6993 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { DataSource } from 'typeorm'; import { EscrowPayoutsBatchEntity } from './escrow-payouts-batch.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/cvat.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/cvat.ts index de660eae41..d1a6f89d26 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/cvat.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/cvat.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; -import { CvatJobType } from '../../../common/enums'; -import { CvatManifest } from '../../../common/types'; +import { CvatJobType } from '@/common/enums'; +import { CvatManifest } from '@/common/types'; export function generateCvatManifest(): CvatManifest { return { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/escrow-completion.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/escrow-completion.ts index 082da5e20d..ddaf366c74 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/escrow-completion.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/escrow-completion.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { generateTestnetChainId } from '../../web3/fixtures'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { EscrowCompletionStatus } from '../constants'; import { EscrowCompletionEntity } from '../escrow-completion.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/fortune.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/fortune.ts index cf70a76a07..90527b6fa0 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/fortune.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/fixtures/fortune.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; -import { FortuneJobType } from '../../../common/enums'; -import { FortuneFinalResult, FortuneManifest } from '../../../common/types'; +import { FortuneJobType } from '@/common/enums'; +import { FortuneFinalResult, FortuneManifest } from '@/common/types'; export function generateFortuneManifest(): FortuneManifest { return { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/index.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/index.ts index 1db9914762..079b8418c4 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/index.ts @@ -1,2 +1,4 @@ export { EscrowCompletionModule } from './escrow-completion.module'; export { EscrowCompletionService } from './escrow-completion.service'; +export { EscrowCompletionEntity } from './escrow-completion.entity'; +export { EscrowPayoutsBatchEntity } from './escrow-payouts-batch.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts index d1f276a572..df51cb52d7 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts @@ -2,11 +2,11 @@ import { EscrowClient, EscrowUtils } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import type { OverrideProperties } from 'type-fest'; -import { AUDINO_VALIDATION_META_FILENAME } from '../../../common/constants'; -import { AudinoAnnotationMeta, AudinoManifest } from '../../../common/types'; +import { AUDINO_VALIDATION_META_FILENAME } from '@/common/constants'; +import { AudinoAnnotationMeta, AudinoManifest } from '@/common/types'; -import { StorageService } from '../../storage'; -import { Web3Service } from '../../web3'; +import { StorageService } from '@/modules/storage'; +import { Web3Service } from '@/modules/web3'; import { CalclulatePayoutsInput, diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts index 283bfdfbf5..faa49c243d 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts @@ -7,11 +7,11 @@ import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; import _ from 'lodash'; -import { CvatAnnotationMeta } from '../../../common/types'; +import { CvatAnnotationMeta } from '@/common/types'; -import { StorageService } from '../../storage'; -import { generateTestnetChainId } from '../../web3/fixtures'; -import { Web3Service } from '../../web3'; +import { StorageService } from '@/modules/storage'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; import { CvatPayoutsCalculator } from './cvat-payouts-calculator'; import { generateCvatManifest } from '../fixtures'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts index 87f3c1f36b..46d00d8129 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts @@ -3,11 +3,11 @@ import { Injectable } from '@nestjs/common'; import { ethers } from 'ethers'; import type { OverrideProperties } from 'type-fest'; -import { CVAT_VALIDATION_META_FILENAME } from '../../../common/constants'; -import { CvatAnnotationMeta, CvatManifest } from '../../../common/types'; +import { CVAT_VALIDATION_META_FILENAME } from '@/common/constants'; +import { CvatAnnotationMeta, CvatManifest } from '@/common/types'; -import { StorageService } from '../../storage'; -import { Web3Service } from '../../web3'; +import { StorageService } from '@/modules/storage'; +import { Web3Service } from '@/modules/web3'; import { CalclulatePayoutsInput, diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts index 08f8e6fe25..8ed9420618 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts @@ -4,7 +4,7 @@ import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; import _ from 'lodash'; -import { StorageService } from '../../storage'; +import { StorageService } from '@/modules/storage'; import { generateFortuneManifest, generateFortuneSolution } from '../fixtures'; import { FortunePayoutsCalculator } from './fortune-payouts-calculator'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts index e94e823dab..f9909d02e3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts @@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common'; import { ethers } from 'ethers'; import type { OverrideProperties } from 'type-fest'; -import { FortuneFinalResult, FortuneManifest } from '../../../common/types'; +import { FortuneFinalResult, FortuneManifest } from '@/common/types'; -import { StorageService } from '../../storage'; +import { StorageService } from '@/modules/storage'; import { CalclulatePayoutsInput, diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/module.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/module.ts index 7080cb32ae..d60196f22c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; -import { StorageModule } from '../../storage'; -import { Web3Module } from '../../web3'; +import { StorageModule } from '@/modules/storage'; +import { Web3Module } from '@/modules/web3'; import { AudinoPayoutsCalculator } from './audino-payouts-calculator'; import { CvatPayoutsCalculator } from './cvat-payouts-calculator'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts index faaa20853e..6972d83883 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts @@ -1,5 +1,5 @@ import { ChainId } from '@human-protocol/sdk'; -import { JobManifest } from '../../../common/types'; +import { JobManifest } from '@/common/types'; export type CalculatedPayout = { address: string; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/audino-results-processor.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/audino-results-processor.ts index 7d4a489498..8c6b8a8c61 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/audino-results-processor.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/audino-results-processor.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { AUDINO_RESULTS_ANNOTATIONS_FILENAME } from '../../../common/constants'; -import { AudinoManifest } from '../../../common/types'; +import { AUDINO_RESULTS_ANNOTATIONS_FILENAME } from '@/common/constants'; +import { AudinoManifest } from '@/common/types'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts index 7b07431d43..8ee621d741 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts @@ -2,9 +2,9 @@ import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; import { Test } from '@nestjs/testing'; -import { PgpEncryptionService } from '../../encryption'; -import { StorageService } from '../../storage'; -import { Web3Service } from '../../web3'; +import { PgpEncryptionService } from '@/modules/encryption'; +import { StorageService } from '@/modules/storage'; +import { Web3Service } from '@/modules/web3'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; import { CvatResultsProcessor } from './cvat-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.ts index 25d82a7a7c..6a89d3a626 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { CVAT_RESULTS_ANNOTATIONS_FILENAME } from '../../../common/constants'; -import { CvatManifest } from '../../../common/types'; +import { CVAT_RESULTS_ANNOTATIONS_FILENAME } from '@/common/constants'; +import { CvatManifest } from '@/common/types'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts index 0895ed9e97..576e35516c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts @@ -6,10 +6,10 @@ import { EscrowClient, EscrowUtils } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; import * as crypto from 'crypto'; -import { PgpEncryptionService } from '../../encryption'; -import { StorageService } from '../../storage'; -import { generateTestnetChainId } from '../../web3/fixtures'; -import { Web3Service } from '../../web3'; +import { PgpEncryptionService } from '@/modules/encryption'; +import { StorageService } from '@/modules/storage'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts index fa29f5cd88..0a4080e765 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts @@ -2,12 +2,12 @@ import { ChainId, EscrowClient, EscrowUtils } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import crypto from 'crypto'; -import { ContentType } from '../../../common/enums'; -import { JobManifest } from '../../../common/types'; +import { ContentType } from '@/common/enums'; +import { JobManifest } from '@/common/types'; -import { PgpEncryptionService } from '../../encryption'; -import { StorageService } from '../../storage'; -import { Web3Service } from '../../web3'; +import { PgpEncryptionService } from '@/modules/encryption'; +import { StorageService } from '@/modules/storage'; +import { Web3Service } from '@/modules/web3'; type EscrowFinalResultsDetails = { url: string; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts index 7cdb95f496..22c84e1e6b 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts @@ -2,11 +2,11 @@ import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; import { Test } from '@nestjs/testing'; -import { FortuneFinalResult } from '../../../common/types'; +import { FortuneFinalResult } from '@/common/types'; -import { PgpEncryptionService } from '../../encryption'; -import { StorageService } from '../../storage'; -import { Web3Service } from '../../web3'; +import { PgpEncryptionService } from '@/modules/encryption'; +import { StorageService } from '@/modules/storage'; +import { Web3Service } from '@/modules/web3'; import { generateFortuneManifest, generateFortuneSolution } from '../fixtures'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts index 92ff8d81ef..24f0403f70 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; -import { FortuneFinalResult, FortuneManifest } from '../../../common/types'; +import { FortuneFinalResult, FortuneManifest } from '@/common/types'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/module.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/module.ts index 50f88845b2..4149ac6a5a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; -import { EncryptionModule } from '../../encryption'; -import { StorageModule } from '../../storage'; -import { Web3Module } from '../../web3'; +import { EncryptionModule } from '@/modules/encryption'; +import { StorageModule } from '@/modules/storage'; +import { Web3Module } from '@/modules/web3'; import { AudinoResultsProcessor } from './audino-results-processor'; import { CvatResultsProcessor } from './cvat-results-processor'; diff --git a/packages/apps/reputation-oracle/server/src/modules/health/health.controller.spec.ts b/packages/apps/reputation-oracle/server/src/modules/health/health.controller.spec.ts index a337df5c3e..cccbe61b54 100644 --- a/packages/apps/reputation-oracle/server/src/modules/health/health.controller.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/health/health.controller.spec.ts @@ -7,8 +7,8 @@ import { TerminusModule, TypeOrmHealthIndicator, } from '@nestjs/terminus'; -import { nestLoggerOverride } from '../../logger'; -import { ServerConfigService } from '../../config'; +import { nestLoggerOverride } from '@/logger'; +import { ServerConfigService } from '@/config'; import { HealthController } from './health.controller'; const mockServerConfigService = { diff --git a/packages/apps/reputation-oracle/server/src/modules/health/health.controller.ts b/packages/apps/reputation-oracle/server/src/modules/health/health.controller.ts index 491b78c544..747399928d 100644 --- a/packages/apps/reputation-oracle/server/src/modules/health/health.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/health/health.controller.ts @@ -7,9 +7,9 @@ import { HealthIndicatorResult, TypeOrmHealthIndicator, } from '@nestjs/terminus'; -import { Public } from '../../common/decorators'; -import { ServerConfigService } from '../../config'; -import Environment from '../../utils/environment'; +import { Public } from '@/common/decorators'; +import { ServerConfigService } from '@/config'; +import Environment from '@/utils/environment'; import { PingResponseDto } from './dto/ping-response.dto'; @Public() diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts index 88c8f2fefc..d4a2ebde7f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { KycConfigService } from '../../../config'; +import { KycConfigService } from '@/config'; import { KycEntity } from '../kyc.entity'; import { KycStatus } from '../constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts index 5ea2ee9fe2..6c5760e234 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts @@ -1 +1,3 @@ export { KycModule } from './kyc.module'; +export { KycEntity } from './kyc.entity'; +export { KycStatus } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts index cdabe472c1..4c99c196d3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts @@ -8,7 +8,7 @@ import { import { createHmac } from 'crypto'; import { Request } from 'express'; -import { KycConfigService } from '../../config'; +import { KycConfigService } from '@/config'; @Injectable() export class KycWebhookAuthGuard implements CanActivate { diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts index 4bf41d618f..9122a98522 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts @@ -17,8 +17,8 @@ import { ApiTags, } from '@nestjs/swagger'; -import { Public } from '../../common/decorators'; -import type { RequestWithUser } from '../../common/types'; +import { Public } from '@/common/decorators'; +import type { RequestWithUser } from '@/common/types'; import { StartSessionResponseDto, KycSignedAddressDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts index ec5c62409c..d06992ddf9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts @@ -1,10 +1,10 @@ import { Column, Entity, JoinColumn, OneToOne } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import { KycStatus } from './constants'; -import type { UserEntity } from '../user'; +import type { UserEntity } from '@/modules/user'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'kycs' }) export class KycEntity extends BaseEntity { diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts index 6d895fab85..e9aed9acf9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts @@ -6,7 +6,7 @@ import { } from '@nestjs/common'; import { Request, Response } from 'express'; -import logger from '../../logger'; +import logger from '@/logger'; import { KycError } from './kyc.error'; @Catch(KycError) diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error.ts index dead033221..4d4b9ac3b4 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error.ts @@ -1,4 +1,4 @@ -import { BaseError } from '../../common/errors/base'; +import { BaseError } from '@/common/errors/base'; export enum KycErrorMessage { NOT_FOUND = 'KYC session not found', diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts index 0892c9b8a8..5ea52c4e97 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts @@ -1,8 +1,8 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; -import { UserModule } from '../user'; -import { Web3Module } from '../web3'; +import { UserModule } from '@/modules/user'; +import { Web3Module } from '@/modules/web3'; import { KycController } from './kyc.controller'; import { KycService } from './kyc.service'; import { KycRepository } from './kyc.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts index b34ccddefc..a3bcaa6db7 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { KycEntity } from './kyc.entity'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts index b04dcf9548..45a8b5be9a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts @@ -4,17 +4,17 @@ import { HttpService } from '@nestjs/axios'; import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; -import { generateEthWallet } from '../../../test/fixtures/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { createHttpServiceMock, createHttpServiceResponse, -} from '../../../test/mock-creators/nest'; -import { KycConfigService, Web3ConfigService } from '../../config'; -import { KycStatus } from '../kyc/constants'; -import { UserRepository } from '../user'; -import { generateWorkerUser } from '../user/fixtures'; -import { mockWeb3ConfigService } from '../web3/fixtures'; -import { Web3Service } from '../web3'; +} from '~/test/mock-creators/nest'; +import { KycConfigService, Web3ConfigService } from '@/config'; +import { KycStatus } from './constants'; +import { UserRepository } from '@/modules/user'; +import { generateWorkerUser } from '@/modules/user/fixtures'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; import { UpdateKycStatusDto } from './kyc.dto'; import { KycEntity } from './kyc.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts index 3f53f928c4..fc09fbc2c2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts @@ -3,11 +3,11 @@ import { Injectable } from '@nestjs/common'; import { AxiosError } from 'axios'; import { catchError, firstValueFrom } from 'rxjs'; -import { KycConfigService, Web3ConfigService } from '../../config'; -import logger from '../../logger'; -import * as httpUtils from '../../utils/http'; -import { UserNotFoundError, UserRepository } from '../user'; -import { Web3Service } from '../web3'; +import { KycConfigService, Web3ConfigService } from '@/config'; +import logger from '@/logger'; +import * as httpUtils from '@/utils/http'; +import { UserNotFoundError, UserRepository } from '@/modules/user'; +import { Web3Service } from '@/modules/web3'; import { KycStatus } from './constants'; import { KycSignedAddressDto, UpdateKycStatusDto } from './kyc.dto'; diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/nda/fixtures/index.ts index a6a8b5fbc0..cd99d81b59 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/fixtures/index.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { NDAConfigService } from '../../../config'; +import { NDAConfigService } from '@/config'; export const mockNdaConfigService: Omit = { latestNdaUrl: faker.internet.url(), diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts index 4f8ca6f70f..2d4b5e6189 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.controller.ts @@ -15,8 +15,8 @@ import { ApiTags, } from '@nestjs/swagger'; -import type { RequestWithUser } from '../../common/types'; -import { NDAConfigService } from '../../config'; +import type { RequestWithUser } from '@/common/types'; +import { NDAConfigService } from '@/config'; import { NDASignatureDto } from './nda.dto'; import { NDAErrorFilter } from './nda.error-filter'; diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts index 100e065481..14d0c04ecf 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts @@ -6,7 +6,7 @@ import { } from '@nestjs/common'; import { Request, Response } from 'express'; -import logger from '../../logger'; +import logger from '@/logger'; import { NDAError } from './nda.error'; @Catch(NDAError) diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.error.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.error.ts index 386312829c..8e4f409f44 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.error.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.error.ts @@ -1,4 +1,4 @@ -import { BaseError } from '../../common/errors/base'; +import { BaseError } from '@/common/errors/base'; export enum NDAErrorMessage { INVALID_NDA = 'Invalid NDA URL', diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts index ce7b4973f8..9c2ef2df89 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { UserModule } from '../user'; +import { UserModule } from '@/modules/user'; import { NDAController } from './nda.controller'; import { NDAService } from './nda.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts index 30a61da25d..30d11af346 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts @@ -2,9 +2,9 @@ import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; import { Test, TestingModule } from '@nestjs/testing'; -import { NDAConfigService } from '../../config'; -import { generateWorkerUser } from '../user/fixtures'; -import { UserRepository } from '../user'; +import { NDAConfigService } from '@/config'; +import { generateWorkerUser } from '@/modules/user/fixtures'; +import { UserRepository } from '@/modules/user'; import { NDASignatureDto } from './nda.dto'; import { NDAError, NDAErrorMessage } from './nda.error'; diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts index 3b3d7b540a..ff2e016725 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { UserNotFoundError, UserRepository } from '../user'; -import { NDAConfigService } from '../../config'; +import { UserNotFoundError, UserRepository } from '@/modules/user'; +import { NDAConfigService } from '@/config'; import { NDASignatureDto } from './nda.dto'; import { NDAError, NDAErrorMessage } from './nda.error'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/index.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/index.ts index 5c80613a7c..eccc227703 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/index.ts @@ -1 +1,3 @@ export { QualificationModule } from './qualification.module'; +export { UserQualificationEntity } from './user-qualification.entity'; +export { QualificationEntity } from './qualification.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts index c953357c4d..a5c8c8a83c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts @@ -17,9 +17,9 @@ import { ApiTags, } from '@nestjs/swagger'; -import { Public, Roles } from '../../common/decorators'; -import { RolesAuthGuard } from '../../common/guards'; -import { UserRole } from '../user'; +import { Public, Roles } from '@/common/decorators'; +import { RolesAuthGuard } from '@/common/guards'; +import { UserRole } from '@/modules/user'; import { AssignQualificationDto, CreateQualificationDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts index b8393c96d5..ee33684eda 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index, OneToMany } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import type { UserQualificationEntity } from './user-qualification.entity'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'qualifications' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts index 29cd162877..059ebb74eb 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts @@ -6,7 +6,7 @@ import { } from '@nestjs/common'; import { Request, Response } from 'express'; -import logger from '../../logger'; +import logger from '@/logger'; import { QualificationError, QualificationErrorMessage, diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error.ts index b33fbbd6a8..76b606d8ab 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error.ts @@ -1,4 +1,4 @@ -import { BaseError } from '../../common/errors/base'; +import { BaseError } from '@/common/errors/base'; export enum QualificationErrorMessage { INVALID_EXPIRATION_TIME = 'Qualification should be valid till at least %minExpirationDate%', diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts index f70575cf4a..bfdd62e365 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { UserModule } from '../user'; +import { UserModule } from '@/modules/user'; import { QualificationController } from './qualification.controller'; import { QualificationRepository } from './qualification.repository'; import { QualificationService } from './qualification.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts index 5569b198ac..b6087393d8 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, IsNull, MoreThan } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { QualificationEntity } from './qualification.entity'; type FindOptions = { diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts index 275a3973c8..c5fe1ebdeb 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts @@ -3,11 +3,11 @@ import { createMock } from '@golevelup/ts-jest'; import { ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; -import { generateFutureDate } from '../../../test/fixtures/date'; -import { generateEthWallet } from '../../../test/fixtures/web3'; -import { ServerConfigService } from '../../config'; -import { UserStatus, UserRepository } from '../user'; -import { generateWorkerUser } from '../user/fixtures'; +import { generateFutureDate } from '~/test/fixtures/date'; +import { generateEthWallet } from '~/test/fixtures/web3'; +import { ServerConfigService } from '@/config'; +import { UserStatus, UserRepository } from '@/modules/user'; +import { generateWorkerUser } from '@/modules/user/fixtures'; import { QualificationEntity } from './qualification.entity'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts index ef24fa2681..709cd5047a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@nestjs/common'; import { v4 as uuidV4 } from 'uuid'; -import { ServerConfigService } from '../../config'; -import logger from '../../logger'; -import { UserRepository, UserStatus } from '../user'; +import { ServerConfigService } from '@/config'; +import logger from '@/logger'; +import { UserRepository, UserStatus } from '@/modules/user'; import { QualificationEntity } from './qualification.entity'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts index 2bdf653c43..61ee84194c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts @@ -1,9 +1,9 @@ import { Column, Entity, ManyToOne, Index } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; -import type { QualificationEntity } from '../qualification/qualification.entity'; -import type { UserEntity } from '../user'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; +import type { QualificationEntity } from './qualification.entity'; +import type { UserEntity } from '@/modules/user'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'user_qualifications' }) @Index(['user', 'qualification'], { unique: true }) diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts index 70311a558d..5001111bee 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { UserQualificationEntity } from './user-qualification.entity'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/fixtures/index.ts index 2078488bb5..a15853c4f1 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/fixtures/index.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { generateTestnetChainId } from '../../web3/fixtures'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { ReputationEntityType } from '../constants'; import { ReputationEntity } from '../reputation.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/index.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/index.ts index ef9e41252e..80d4c8cb5f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/index.ts @@ -1,2 +1,3 @@ export { ReputationModule } from './reputation.module'; export { ReputationService } from './reputation.service'; +export { ReputationEntity } from './reputation.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.controller.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.controller.ts index 974b91c0b1..839230de3d 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.controller.ts @@ -1,8 +1,8 @@ import { Controller, Get, Query } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; -import { Public } from '../../common/decorators'; -import { SortDirection } from '../../common/enums'; +import { Public } from '@/common/decorators'; +import { SortDirection } from '@/common/enums'; import { MAX_REPUTATION_ITEMS_PER_PAGE, ReputationOrderBy } from './constants'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.dto.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.dto.ts index d78e3b2697..cad942c8b7 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.dto.ts @@ -3,8 +3,8 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { IsEthereumAddress, IsOptional, Max, Min } from 'class-validator'; -import { SortDirection } from '../../common/enums'; -import { IsChainId, IsLowercasedEnum } from '../../common/validators'; +import { SortDirection } from '@/common/enums'; +import { IsChainId, IsLowercasedEnum } from '@/common/validators'; import { MAX_REPUTATION_ITEMS_PER_PAGE, diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.entity.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.entity.ts index 63b7596d37..4bae3b5a18 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import { ReputationEntityType } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts index c30001a407..ba8750d47c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts @@ -1,7 +1,7 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; -import { Web3Module } from '../web3'; +import { Web3Module } from '@/modules/web3'; import { ReputationService } from './reputation.service'; import { ReputationRepository } from './reputation.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.repository.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.repository.ts index 930776ce42..8846cbca70 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.repository.ts @@ -2,8 +2,8 @@ import { ChainId } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, In } from 'typeorm'; -import { SortDirection } from '../../common/enums'; -import { BaseRepository } from '../../database'; +import { SortDirection } from '@/common/enums'; +import { BaseRepository } from '@/database'; import { ReputationEntityType, ReputationOrderBy } from './constants'; import { ReputationEntity } from './reputation.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts index b1abf2827d..96d59140ed 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts @@ -5,13 +5,13 @@ import { faker } from '@faker-js/faker'; import { EscrowClient } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; -import { ReputationConfigService, Web3ConfigService } from '../../config'; +import { ReputationConfigService, Web3ConfigService } from '@/config'; import { generateTestnetChainId, mockWeb3ConfigService, -} from '../web3/fixtures'; -import { Web3Service } from '../web3'; +} from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; import { generateRandomScorePoints, diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts index c3e92f1cd6..c7e8c46166 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { ChainId, EscrowClient } from '@human-protocol/sdk'; -import { SortDirection } from '../../common/enums'; -import { isDuplicatedError } from '../../database'; -import { ReputationConfigService, Web3ConfigService } from '../../config'; +import { SortDirection } from '@/common/enums'; +import { isDuplicatedError } from '@/database'; +import { ReputationConfigService, Web3ConfigService } from '@/config'; -import { Web3Service } from '../web3'; +import { Web3Service } from '@/modules/web3'; import { INITIAL_REPUTATION, diff --git a/packages/apps/reputation-oracle/server/src/modules/storage/storage.module.ts b/packages/apps/reputation-oracle/server/src/modules/storage/storage.module.ts index 3ddb44fb84..e75406d305 100644 --- a/packages/apps/reputation-oracle/server/src/modules/storage/storage.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/storage/storage.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { EncryptionModule } from '../encryption'; +import { EncryptionModule } from '@/modules/encryption'; import { StorageService } from './storage.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts index 95d46abde7..c3eeee684b 100644 --- a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts @@ -5,11 +5,11 @@ import { faker } from '@faker-js/faker'; import { Test } from '@nestjs/testing'; import { Client as MinioClient } from 'minio'; -import { ContentType } from '../../common/enums'; -import { S3ConfigService } from '../../config'; -import * as httpUtils from '../../utils/http'; +import { ContentType } from '@/common/enums'; +import { S3ConfigService } from '@/config'; +import * as httpUtils from '@/utils/http'; -import { PgpEncryptionService } from '../encryption'; +import { PgpEncryptionService } from '@/modules/encryption'; import { MinioErrorCodes } from './minio.constants'; import { StorageService } from './storage.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts index 8a83b70a73..6264f259b3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@nestjs/common'; import * as Minio from 'minio'; -import { ContentType } from '../../common/enums'; -import { S3ConfigService } from '../../config'; -import logger from '../../logger'; -import * as httpUtils from '../../utils/http'; +import { ContentType } from '@/common/enums'; +import { S3ConfigService } from '@/config'; +import logger from '@/logger'; +import * as httpUtils from '@/utils/http'; -import { PgpEncryptionService } from '../encryption'; +import { PgpEncryptionService } from '@/modules/encryption'; import { MinioErrorCodes } from './minio.constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/sitekey.ts b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/sitekey.ts index 5c404f14b9..44b4794727 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/sitekey.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/sitekey.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { generateEthWallet } from '../../../../test/fixtures/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { SiteKeyEntity, SiteKeyType } from '../site-key.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts index 51e1d5fabb..349f927750 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts @@ -1,10 +1,10 @@ import { faker } from '@faker-js/faker'; import { SetNonNullable } from 'type-fest'; -import { generateEthWallet } from '../../../../test/fixtures/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; -import * as securityUtils from '../../../utils/security'; -import * as web3Utils from '../../../utils/web3'; +import * as securityUtils from '@/utils/security'; +import * as web3Utils from '@/utils/web3'; import { OperatorUserEntity, Web2UserEntity } from '../types'; import { Role, UserStatus } from '../user.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/index.ts b/packages/apps/reputation-oracle/server/src/modules/user/index.ts index ca741e834e..7c9fc938db 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/index.ts @@ -1,5 +1,5 @@ export { SiteKeyRepository } from './site-key.repository'; -export { SiteKeyType } from './site-key.entity'; +export { SiteKeyType, SiteKeyEntity } from './site-key.entity'; export type * from './types'; export { UserEntity, UserStatus, Role as UserRole } from './user.entity'; export { UserNotFoundError } from './user.error'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/site-key.entity.ts b/packages/apps/reputation-oracle/server/src/modules/user/site-key.entity.ts index 090c1e9546..0f5d7a939f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/site-key.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/site-key.entity.ts @@ -1,7 +1,7 @@ import { Entity, Column, JoinColumn, ManyToOne, Unique } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import type { UserEntity } from './user.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/site-key.repository.ts b/packages/apps/reputation-oracle/server/src/modules/user/site-key.repository.ts index abeead2eaf..6903f8bce4 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/site-key.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/site-key.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { SiteKeyEntity, SiteKeyType } from './site-key.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts index de3681708d..40e15f3026 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts @@ -17,12 +17,12 @@ import { UseFilters, } from '@nestjs/common'; -import { Public } from '../../common/decorators'; -import { SignatureType } from '../../common/enums'; -import type { RequestWithUser } from '../../common/types'; -import { Web3ConfigService } from '../../config'; -import { HCaptchaGuard } from '../../integrations/hcaptcha/hcaptcha.guard'; -import * as web3Utils from '../../utils/web3'; +import { Public } from '@/common/decorators'; +import { SignatureType } from '@/common/enums'; +import type { RequestWithUser } from '@/common/types'; +import { Web3ConfigService } from '@/config'; +import { HCaptchaGuard } from '@/integrations/hcaptcha/hcaptcha.guard'; +import * as web3Utils from '@/utils/web3'; import { DisableOperatorDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.dto.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.dto.ts index 11e8ec4c51..1686800868 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.dto.ts @@ -1,11 +1,8 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsEthereumAddress, IsOptional, IsString } from 'class-validator'; -import { SignatureType } from '../../common/enums'; -import { - IsLowercasedEnum, - IsValidWeb3Signature, -} from '../../common/validators'; +import { SignatureType } from '@/common/enums'; +import { IsLowercasedEnum, IsValidWeb3Signature } from '@/common/validators'; export class RegisterLabelerResponseDto { @ApiProperty({ name: 'site_key' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts index 6d4f3ce22c..752df76d4a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts @@ -1,11 +1,11 @@ import { Exclude } from 'class-transformer'; import { Column, Entity, OneToMany, OneToOne } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; -import type { KycEntity } from '../kyc/kyc.entity'; -import type { UserQualificationEntity } from '../qualification/user-qualification.entity'; +import type { KycEntity } from '@/modules/kyc'; +import type { UserQualificationEntity } from '@/modules/qualification'; import type { SiteKeyEntity } from './site-key.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.error-filter.ts index 378df84c65..d8f8f49f5a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.error-filter.ts @@ -6,7 +6,7 @@ import { } from '@nestjs/common'; import { Request, Response } from 'express'; -import logger from '../../logger'; +import logger from '@/logger'; import { UserError, diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.error.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.error.ts index e369d88bbb..bd6efa028c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.error.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.error.ts @@ -1,4 +1,4 @@ -import { BaseError } from '../../common/errors/base'; +import { BaseError } from '@/common/errors/base'; export enum UserErrorMessage { INVALID_ROLE = 'Invalid user role', diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts index 6c34d08d3c..eb177d8be6 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; -import { HCaptchaModule } from '../../integrations/hcaptcha'; +import { HCaptchaModule } from '@/integrations/hcaptcha'; -import { Web3Module } from '../web3'; +import { Web3Module } from '@/modules/web3'; import { SiteKeyRepository } from './site-key.repository'; import { UserController } from './user.controller'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts index c2161dbc95..b37ab62aec 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, In } from 'typeorm'; -import { BaseRepository } from '../../database'; +import { BaseRepository } from '@/database'; import { Role, UserEntity } from './user.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts index 5164f97a55..6074bd3234 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts @@ -5,17 +5,17 @@ import { createMock } from '@golevelup/ts-jest'; import { KVStoreClient, KVStoreUtils } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; -import { generateEthWallet } from '../../../test/fixtures/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; -import { SignatureType } from '../../common/enums'; -import { Web3ConfigService } from '../../config'; -import { HCaptchaService } from '../../integrations/hcaptcha/hcaptcha.service'; -import * as web3Utils from '../../utils/web3'; +import { SignatureType } from '@/common/enums'; +import { Web3ConfigService } from '@/config'; +import { HCaptchaService } from '@/integrations/hcaptcha/hcaptcha.service'; +import * as web3Utils from '@/utils/web3'; -import { KycStatus } from '../kyc/constants'; -import { generateKycEntity } from '../kyc/fixtures'; -import { mockWeb3ConfigService } from '../web3/fixtures'; -import { Web3Service } from '../web3/web3.service'; +import { KycStatus } from '@/modules/kyc'; +import { generateKycEntity } from '@/modules/kyc/fixtures'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; +import { Web3Service } from '@/modules/web3'; import { generateSiteKeyEntity, diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts index 7d78951c6b..4b2513baa6 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts @@ -1,13 +1,13 @@ import { KVStoreClient, KVStoreUtils } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; -import { SignatureType } from '../../common/enums'; -import { Web3ConfigService } from '../../config'; -import { HCaptchaService } from '../../integrations/hcaptcha/hcaptcha.service'; -import * as web3Utils from '../../utils/web3'; +import { SignatureType } from '@/common/enums'; +import { Web3ConfigService } from '@/config'; +import { HCaptchaService } from '@/integrations/hcaptcha/hcaptcha.service'; +import * as web3Utils from '@/utils/web3'; -import { KycStatus } from '../kyc/constants'; -import { Web3Service } from '../web3/web3.service'; +import { KycStatus } from '@/modules/kyc'; +import { Web3Service } from '@/modules/web3'; import { SiteKeyEntity, SiteKeyType } from './site-key.entity'; import { SiteKeyRepository } from './site-key.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts index ade74b3553..33ddb43b84 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts @@ -1,9 +1,6 @@ import { faker } from '@faker-js/faker'; -import { - Web3ConfigService, - Web3Network, -} from '../../../config/web3-config.service'; -import { generateEthWallet } from '../../../../test/fixtures/web3'; +import { Web3ConfigService, Web3Network } from '@/config'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { supportedChainIdsByNetwork } from '../web3.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts index 10af353e89..0a2cc6bae0 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts @@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker'; import { Test } from '@nestjs/testing'; import { FeeData, JsonRpcProvider, Provider } from 'ethers'; -import { Web3ConfigService } from '../../config'; +import { Web3ConfigService } from '@/config'; import { Web3Service } from './web3.service'; import type { WalletWithProvider } from './types'; diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts index 7fa5ece5c7..189673cf2d 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts @@ -1,7 +1,7 @@ import { ChainId } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { Wallet, ethers } from 'ethers'; -import { Web3ConfigService, Web3Network } from '../../config'; +import { Web3ConfigService, Web3Network } from '@/config'; import type { Chain, WalletWithProvider } from './types'; export const supportedChainIdsByNetwork = { diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts index da17bbb84a..9ead719155 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import * as crypto from 'crypto'; import stringify from 'json-stable-stringify'; -import { generateTestnetChainId } from '../../web3/fixtures'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { IncomingWebhookStatus, OutgoingWebhookEventType, diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/index.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/index.ts index 6230af5d87..204d40950f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/index.ts @@ -3,3 +3,5 @@ export { IncomingWebhookModule } from './webhook-incoming.module'; export { IncomingWebhookService } from './webhook-incoming.service'; export { OutgoingWebhookModule } from './webhook-outgoing.module'; export { OutgoingWebhookService } from './webhook-outgoing.service'; +export { IncomingWebhookEntity } from './webhook-incoming.entity'; +export { OutgoingWebhookEntity } from './webhook-outgoing.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts index 61422aa418..bd0ad85656 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import { IncomingWebhookStatus } from './types'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'webhook_incoming' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts index 7058fbdc19..687a881099 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts @@ -1,7 +1,7 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; -import { EscrowCompletionModule } from '../escrow-completion'; +import { EscrowCompletionModule } from '@/modules/escrow-completion'; import { WebhookController } from './webhook.controller'; import { IncomingWebhookRepository } from './webhook-incoming.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts index 5913845c8c..6fe518294f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts @@ -1,8 +1,8 @@ import { Injectable } from '@nestjs/common'; import { DataSource, LessThanOrEqual } from 'typeorm'; -import { ServerConfigService } from '../../config'; -import { BaseRepository } from '../../database'; +import { ServerConfigService } from '@/config'; +import { BaseRepository } from '@/database'; import { IncomingWebhookStatus } from './types'; import { IncomingWebhookEntity } from './webhook-incoming.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts index 3f3ea6e5ea..208894074e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts @@ -2,10 +2,10 @@ import { faker } from '@faker-js/faker'; import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; -import { DatabaseError, DatabaseErrorMessages } from '../../database'; -import { ServerConfigService } from '../../config'; -import { EscrowCompletionService } from '../escrow-completion'; -import { generateTestnetChainId } from '../web3/fixtures'; +import { DatabaseError, DatabaseErrorMessages } from '@/database'; +import { ServerConfigService } from '@/config'; +import { EscrowCompletionService } from '@/modules/escrow-completion'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { generateIncomingWebhook } from './fixtures'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts index b877cca8ec..a221546dae 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; -import { BACKOFF_INTERVAL_SECONDS } from '../../common/constants'; -import { isDuplicatedError } from '../../database'; -import { ServerConfigService } from '../../config'; -import { EscrowCompletionService } from '../escrow-completion'; -import { calculateExponentialBackoffMs } from '../../utils/backoff'; -import logger from '../../logger'; +import { BACKOFF_INTERVAL_SECONDS } from '@/common/constants'; +import { isDuplicatedError } from '@/database'; +import { ServerConfigService } from '@/config'; +import { EscrowCompletionService } from '@/modules/escrow-completion'; +import { calculateExponentialBackoffMs } from '@/utils/backoff'; +import logger from '@/logger'; import { IncomingWebhookData, IncomingWebhookStatus } from './types'; import { IncomingWebhookEntity } from './webhook-incoming.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts index bf13bf52de..a929d5c2e3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; -import { BaseEntity } from '../../database'; +import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import { OutgoingWebhookStatus } from './types'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'webhook_outgoing' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.module.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.module.ts index c6a07f9209..7b6b58fc87 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.module.ts @@ -1,7 +1,7 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; -import { Web3Module } from '../web3'; +import { Web3Module } from '@/modules/web3'; import { OutgoingWebhookRepository } from './webhook-outgoing.repository'; import { OutgoingWebhookService } from './webhook-outgoing.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts index f72f7a9bdb..4b908418db 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts @@ -1,8 +1,8 @@ import { Injectable } from '@nestjs/common'; import { DataSource, LessThanOrEqual } from 'typeorm'; -import { ServerConfigService } from '../../config'; -import { BaseRepository } from '../../database'; +import { ServerConfigService } from '@/config'; +import { BaseRepository } from '@/database'; import { OutgoingWebhookStatus } from './types'; import { OutgoingWebhookEntity } from './webhook-outgoing.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts index f5d3637be4..7b92ee4aef 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts @@ -8,12 +8,12 @@ import stringify from 'json-stable-stringify'; import { createHttpServiceMock, createHttpServiceResponse, -} from '../../../test/mock-creators/nest'; -import { HEADER_SIGNATURE_KEY } from '../../common/constants'; -import { ServerConfigService, Web3ConfigService } from '../../config'; -import { transformKeysFromCamelToSnake } from '../../utils/case-converters'; -import { signMessage } from '../../utils/web3'; -import { mockWeb3ConfigService } from '../web3/fixtures'; +} from '~/test/mock-creators/nest'; +import { HEADER_SIGNATURE_KEY } from '@/common/constants'; +import { ServerConfigService, Web3ConfigService } from '@/config'; +import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; +import { signMessage } from '@/utils/web3'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; import { generateOutgoingWebhookPayload, generateOutgoingWebhook, diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts index c2fb0e56a4..e8a6704871 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts @@ -7,13 +7,13 @@ import { firstValueFrom } from 'rxjs'; import { BACKOFF_INTERVAL_SECONDS, HEADER_SIGNATURE_KEY, -} from '../../common/constants'; -import { ServerConfigService, Web3ConfigService } from '../../config'; -import { calculateExponentialBackoffMs } from '../../utils/backoff'; -import { transformKeysFromCamelToSnake } from '../../utils/case-converters'; -import { formatAxiosError } from '../../utils/http'; -import { signMessage } from '../../utils/web3'; -import logger from '../../logger'; +} from '@/common/constants'; +import { ServerConfigService, Web3ConfigService } from '@/config'; +import { calculateExponentialBackoffMs } from '@/utils/backoff'; +import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; +import { formatAxiosError } from '@/utils/http'; +import { signMessage } from '@/utils/web3'; +import logger from '@/logger'; import { OutgoingWebhookStatus } from './types'; import { OutgoingWebhookEntity } from './webhook-outgoing.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts index 3b56628c6c..3b876b9a0a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts @@ -8,9 +8,9 @@ import { ApiTags, } from '@nestjs/swagger'; -import { HEADER_SIGNATURE_KEY } from '../../common/constants'; -import { Public } from '../../common/decorators'; -import { AuthSignatureRole, SignatureAuthGuard } from '../../common/guards'; +import { HEADER_SIGNATURE_KEY } from '@/common/constants'; +import { Public } from '@/common/decorators'; +import { AuthSignatureRole, SignatureAuthGuard } from '@/common/guards'; import { IncomingWebhookService } from './webhook-incoming.service'; import { IncomingWebhookDto } from './webhook.dto'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts index 7f04826bd3..2a87f875da 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts @@ -2,7 +2,7 @@ import { ChainId } from '@human-protocol/sdk'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsEthereumAddress, IsObject, IsOptional } from 'class-validator'; -import { IsChainId, IsLowercasedEnum } from '../../common/validators'; +import { IsChainId, IsLowercasedEnum } from '@/common/validators'; import { IncomingWebhookEventType } from './types'; export class IncomingWebhookDto { diff --git a/packages/apps/reputation-oracle/server/src/utils/backoff.ts b/packages/apps/reputation-oracle/server/src/utils/backoff.ts index 42fdad0760..faa433401a 100644 --- a/packages/apps/reputation-oracle/server/src/utils/backoff.ts +++ b/packages/apps/reputation-oracle/server/src/utils/backoff.ts @@ -1,4 +1,4 @@ -import { BACKOFF_INTERVAL_SECONDS } from '../common/constants'; +import { BACKOFF_INTERVAL_SECONDS } from '@/common/constants'; export function calculateExponentialBackoffMs( retriesCount: number, diff --git a/packages/apps/reputation-oracle/server/src/utils/http.ts b/packages/apps/reputation-oracle/server/src/utils/http.ts index 343d9924c5..3789ec0849 100644 --- a/packages/apps/reputation-oracle/server/src/utils/http.ts +++ b/packages/apps/reputation-oracle/server/src/utils/http.ts @@ -1,7 +1,7 @@ import axios, { AxiosError } from 'axios'; import { Readable } from 'stream'; -import { BaseError } from '../common/errors/base'; +import { BaseError } from '@/common/errors/base'; export function formatAxiosError(error: AxiosError) { return { diff --git a/packages/apps/reputation-oracle/server/src/utils/manifest.ts b/packages/apps/reputation-oracle/server/src/utils/manifest.ts index fb0afbac57..a8fdea9e6a 100644 --- a/packages/apps/reputation-oracle/server/src/utils/manifest.ts +++ b/packages/apps/reputation-oracle/server/src/utils/manifest.ts @@ -1,5 +1,5 @@ -import { AudinoJobType, CvatJobType, FortuneJobType } from '../common/enums'; -import { JobManifest, JobRequestType } from '../common/types'; +import { AudinoJobType, CvatJobType, FortuneJobType } from '@/common/enums'; +import { JobManifest, JobRequestType } from '@/common/types'; const fortuneJobTypes = Object.values(FortuneJobType); diff --git a/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts b/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts index 666e1c1ba5..dda0be8c2f 100644 --- a/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts +++ b/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { generateEthWallet } from '../../test/fixtures/web3'; +import { generateEthWallet } from '@/test/fixtures/web3'; import * as web3Utils from './web3'; From 3b13bd44e720034d4822c9230ca49fe328d73ea2 Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Tue, 12 Aug 2025 13:10:36 +0300 Subject: [PATCH 4/6] chore: fix migrations setup --- .../apps/reputation-oracle/server/package.json | 15 ++++++++------- .../server/typeorm-migrations-datasource.ts | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/apps/reputation-oracle/server/package.json b/packages/apps/reputation-oracle/server/package.json index eec767810c..eda97c9c80 100644 --- a/packages/apps/reputation-oracle/server/package.json +++ b/packages/apps/reputation-oracle/server/package.json @@ -13,19 +13,20 @@ "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/src/main", - "migration:create": "yarn build && typeorm-ts-node-commonjs migration:create", - "migration:generate": "yarn build && typeorm-ts-node-commonjs migration:generate -d typeorm-migrations-datasource.ts", - "migration:revert": "yarn build && typeorm-ts-node-commonjs migration:revert -d typeorm-migrations-datasource.ts", - "migration:run": "yarn build && typeorm-ts-node-commonjs migration:run -d typeorm-migrations-datasource.ts", - "migration:show": "yarn build && typeorm-ts-node-commonjs migration:show -d typeorm-migrations-datasource.ts", + "migration:create": "yarn typeorm migration:create", + "migration:generate": "yarn typeorm migration:generate -d typeorm-migrations-datasource.ts", + "migration:revert": "yarn typeorm migration:revert -d typeorm-migrations-datasource.ts", + "migration:run": "yarn typeorm migration:run -d typeorm-migrations-datasource.ts", + "migration:show": "yarn typeorm migration:show -d typeorm-migrations-datasource.ts", "setup:local": "ts-node ./scripts/setup-staking.ts && LOCAL=true yarn setup:kvstore", "setup:kvstore": "ts-node ./scripts/setup-kv-store.ts", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "lint": "eslint \"{src,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "generate-env-doc": "ts-node scripts/generate-env-doc.ts" + "generate-env-doc": "ts-node scripts/generate-env-doc.ts", + "typeorm": "typeorm-ts-node-commonjs" }, "dependencies": { "@human-protocol/core": "workspace:*", diff --git a/packages/apps/reputation-oracle/server/typeorm-migrations-datasource.ts b/packages/apps/reputation-oracle/server/typeorm-migrations-datasource.ts index bc0d308f37..2b079f0d57 100644 --- a/packages/apps/reputation-oracle/server/typeorm-migrations-datasource.ts +++ b/packages/apps/reputation-oracle/server/typeorm-migrations-datasource.ts @@ -29,8 +29,8 @@ export default new DataSource({ ssl: process.env.POSTGRES_SSL?.toLowerCase() === 'true', synchronize: false, migrationsRun: true, - migrations: ['dist/src/database/migrations/*{.ts,.js}'], + migrations: ['src/database/migrations/*.ts'], migrationsTableName: 'migrations_typeorm', namingStrategy: new SnakeNamingStrategy(), - entities: ['dist/src/**/*.entity{.ts,.js}'], + entities: ['src/modules/**/*.entity.ts'], }); From 6c2a7dbb8ed823ff0c3c31ba29b8a0ae910fbaa6 Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Tue, 12 Aug 2025 14:06:00 +0300 Subject: [PATCH 5/6] refactor: apply new lint config --- .../reputation-oracle/server/.eslintrc.js | 34 -- .../server/eslint.config.mjs | 58 ++++ .../reputation-oracle/server/package.json | 16 +- .../server/src/app.controller.ts | 1 + .../server/src/app.module.ts | 14 +- .../server/src/common/decorators/index.ts | 1 + .../src/common/filters/exception.filter.ts | 3 +- .../server/src/common/guards/jwt.auth.ts | 2 + .../server/src/common/guards/roles.auth.ts | 7 +- .../src/common/guards/signature.auth.spec.ts | 14 +- .../src/common/guards/signature.auth.ts | 21 +- .../transform.interceptor.spec.ts | 4 +- .../interceptors/transform.interceptor.ts | 3 +- .../server/src/common/types/request.ts | 2 +- .../server/src/common/validators/password.ts | 2 +- .../server/src/common/validators/web3.ts | 2 +- .../server/src/config/config.module.ts | 2 +- .../server/src/config/env-schema.ts | 1 + .../server/src/database/base.repository.ts | 7 +- .../server/src/database/database.module.ts | 16 +- .../server/src/database/errors.ts | 2 +- .../1752590727473-InitialMigration.ts | 1 + .../typeorm/typeorm-logger.service.ts | 11 +- .../integrations/hcaptcha/fixtures/index.ts | 1 + .../integrations/hcaptcha/hcaptcha.guard.ts | 3 +- .../integrations/hcaptcha/hcaptcha.module.ts | 1 + .../hcaptcha/hcaptcha.service.spec.ts | 5 +- .../slack-bot-app/slack-bot-app.spec.ts | 13 +- .../slack-bot-app/slack-bot-app.ts | 19 +- .../apps/reputation-oracle/server/src/main.ts | 6 +- .../src/modules/abuse/abuse-slack-bot.spec.ts | 4 +- .../src/modules/abuse/abuse-slack-bot.ts | 8 +- .../src/modules/abuse/abuse.controller.ts | 9 +- .../server/src/modules/abuse/abuse.dto.ts | 1 + .../server/src/modules/abuse/abuse.entity.ts | 1 + .../server/src/modules/abuse/abuse.module.ts | 2 +- .../src/modules/abuse/abuse.repository.ts | 1 + .../src/modules/abuse/abuse.service.spec.ts | 48 +-- .../server/src/modules/abuse/abuse.service.ts | 11 +- .../src/modules/abuse/fixtures/index.ts | 4 +- .../server/src/modules/abuse/types.ts | 4 + .../src/modules/auth/auth.controller.ts | 20 +- .../src/modules/auth/auth.service.spec.ts | 11 +- .../server/src/modules/auth/auth.service.ts | 23 +- .../src/modules/auth/dto/sign-up.dto.ts | 1 + .../src/modules/auth/jwt-http-strategy.ts | 9 +- .../server/src/modules/auth/token.entity.ts | 2 +- .../src/modules/auth/token.repository.ts | 1 + .../src/modules/cron-job/cron-job.module.ts | 2 +- .../modules/cron-job/cron-job.service.spec.ts | 3 + .../src/modules/cron-job/cron-job.service.ts | 1 - .../src/modules/cron-job/fixtures/index.ts | 2 +- .../server/src/modules/email/email.module.ts | 2 +- .../server/src/modules/email/email.service.ts | 2 +- .../modules/email/sendgrid.service.spec.ts | 17 +- .../src/modules/email/sendgrid.service.ts | 3 +- .../encryption/pgp-encryption.service.spec.ts | 6 +- .../encryption/pgp-encryption.service.ts | 1 - .../escrow-completion.module.ts | 3 +- .../escrow-completion.service.spec.ts | 48 +-- .../escrow-completion.service.ts | 25 +- .../escrow-payouts-batch.entity.ts | 2 +- .../escrow-payouts-batch.repository.ts | 4 +- .../audino-payouts-calculator.ts | 1 - .../cvat-payouts-calculator.spec.ts | 5 +- .../cvat-payouts-calculator.ts | 1 - .../fortune-payouts-calculator.spec.ts | 2 +- .../fortune-payouts-calculator.ts | 1 - .../payouts-calculation/types.ts | 1 + .../cvat-results-processor.spec.ts | 4 +- .../escrow-results-processor.spec.ts | 18 +- .../escrow-results-processor.ts | 4 +- .../fortune-results-processor.spec.ts | 3 +- .../fortune-results-processor.ts | 2 +- .../modules/health/health.controller.spec.ts | 6 +- .../src/modules/health/health.controller.ts | 2 + .../server/src/modules/kyc/fixtures/index.ts | 3 +- .../src/modules/kyc/kyc-webhook-auth.guard.ts | 3 +- .../server/src/modules/kyc/kyc.controller.ts | 3 +- .../server/src/modules/kyc/kyc.entity.ts | 4 +- .../src/modules/kyc/kyc.error-filter.ts | 1 + .../server/src/modules/kyc/kyc.module.ts | 3 +- .../server/src/modules/kyc/kyc.repository.ts | 1 + .../src/modules/kyc/kyc.service.spec.ts | 16 +- .../server/src/modules/kyc/kyc.service.ts | 2 +- .../src/modules/nda/nda.error-filter.ts | 1 + .../server/src/modules/nda/nda.module.ts | 1 + .../src/modules/nda/nda.service.spec.ts | 6 +- .../server/src/modules/nda/nda.service.ts | 3 +- .../qualification/qualification.controller.ts | 1 + .../qualification/qualification.entity.ts | 1 + .../qualification.error-filter.ts | 1 + .../qualification/qualification.module.ts | 1 + .../qualification/qualification.repository.ts | 1 + .../qualification.service.spec.ts | 4 +- .../user-qualification.entity.ts | 3 +- .../user-qualification.repository.ts | 1 + .../modules/reputation/reputation.module.ts | 4 +- .../reputation/reputation.service.spec.ts | 9 +- .../modules/reputation/reputation.service.ts | 5 +- .../modules/storage/storage.service.spec.ts | 5 +- .../src/modules/storage/storage.service.ts | 3 +- .../server/src/modules/user/fixtures/user.ts | 3 +- .../src/modules/user/user.controller.ts | 14 +- .../server/src/modules/user/user.entity.ts | 1 - .../server/src/modules/user/user.module.ts | 1 - .../src/modules/user/user.service.spec.ts | 10 +- .../server/src/modules/user/user.service.ts | 7 +- .../server/src/modules/web3/fixtures/index.ts | 1 + .../server/src/modules/web3/types.ts | 1 - .../src/modules/web3/web3.service.spec.ts | 7 +- .../server/src/modules/web3/web3.service.ts | 2 + .../src/modules/webhook/fixtures/index.ts | 4 +- .../webhook/webhook-incoming.entity.ts | 1 + .../webhook/webhook-incoming.module.ts | 2 +- .../webhook/webhook-incoming.repository.ts | 1 + .../webhook/webhook-incoming.service.spec.ts | 2 +- .../webhook/webhook-incoming.service.ts | 4 +- .../webhook/webhook-outgoing.entity.ts | 1 + .../webhook/webhook-outgoing.repository.ts | 1 + .../webhook/webhook-outgoing.service.spec.ts | 14 +- .../webhook/webhook-outgoing.service.ts | 18 +- .../src/modules/webhook/webhook.controller.ts | 1 - .../server/src/modules/webhook/webhook.dto.ts | 1 + .../server/src/utils/backoff.spec.ts | 1 + .../server/src/utils/case-converters.spec.ts | 1 + .../server/src/utils/http.spec.ts | 9 +- .../server/src/utils/http.ts | 5 +- .../server/src/utils/web3.spec.ts | 2 +- .../server/test/mock-creators/nest.ts | 2 +- yarn.lock | 302 +++++++++++++++++- 131 files changed, 780 insertions(+), 328 deletions(-) delete mode 100644 packages/apps/reputation-oracle/server/.eslintrc.js create mode 100644 packages/apps/reputation-oracle/server/eslint.config.mjs diff --git a/packages/apps/reputation-oracle/server/.eslintrc.js b/packages/apps/reputation-oracle/server/.eslintrc.js deleted file mode 100644 index 4517e5977d..0000000000 --- a/packages/apps/reputation-oracle/server/.eslintrc.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-unused-vars': ['error', { - "args": "all", - "argsIgnorePattern": "^_", - "caughtErrors": "all", - "caughtErrorsIgnorePattern": "^noop", - "destructuredArrayIgnorePattern": "^_", - "varsIgnorePattern": "^_", - "ignoreRestSiblings": true - }] - }, -}; diff --git a/packages/apps/reputation-oracle/server/eslint.config.mjs b/packages/apps/reputation-oracle/server/eslint.config.mjs new file mode 100644 index 0000000000..d9ee05f208 --- /dev/null +++ b/packages/apps/reputation-oracle/server/eslint.config.mjs @@ -0,0 +1,58 @@ +// @ts-check +import eslint from '@eslint/js'; +import globals from 'globals'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import * as importPlugin from 'eslint-plugin-import'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + { + ignores: ['eslint.config.mjs', 'dist'], + }, + eslint.configs.recommended, + tseslint.configs.recommended, + eslintPluginPrettierRecommended, + { + languageOptions: { + globals: { + ...globals.node, + ...globals.jest, + }, + sourceType: 'module', + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, + plugins: { + 'import': importPlugin, + }, + rules: { + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-floating-promises': 'warn', + '@typescript-eslint/no-unsafe-argument': 'warn', + '@typescript-eslint/no-unused-vars': ['error', { + "args": "all", + "argsIgnorePattern": "^_", + "caughtErrors": "all", + "caughtErrorsIgnorePattern": "^noop", + "destructuredArrayIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "ignoreRestSiblings": true + }], + 'import/order': [ + 'warn', + { + alphabetize: { order: 'asc', caseInsensitive: true }, + 'newlines-between': 'always', + groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']], + }, + ], + }, + settings: { + 'import/resolver': { + typescript: {}, + }, + }, + }, +); \ No newline at end of file diff --git a/packages/apps/reputation-oracle/server/package.json b/packages/apps/reputation-oracle/server/package.json index eda97c9c80..d326c19c1a 100644 --- a/packages/apps/reputation-oracle/server/package.json +++ b/packages/apps/reputation-oracle/server/package.json @@ -71,6 +71,7 @@ "zxcvbn": "^4.4.2" }, "devDependencies": { + "@eslint/js": "^9.33.0", "@faker-js/faker": "^9.4.0", "@golevelup/ts-jest": "^0.6.1", "@nestjs/cli": "^10.3.2", @@ -83,20 +84,21 @@ "@types/node": "22.10.5", "@types/uuid": "^10.0.0", "@types/zxcvbn": "4.4.5", - "@typescript-eslint/eslint-plugin": "^5.0.0", - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^8.55.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.2.1", + "eslint": "^9.33.0", + "eslint-config-prettier": "^10.1.8", + "eslint-import-resolver-typescript": "^4.4.4", + "eslint-plugin-import": "^2.32.0", + "eslint-plugin-prettier": "^5.5.4", + "globals": "^16.3.0", "jest": "29.7.0", "nock": "^14.0.3", "prettier": "^3.4.2", - "source-map-support": "^0.5.20", "ts-jest": "29.2.5", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", "type-fest": "^4.37.0", - "typescript": "^5.6.3" + "typescript": "^5.9.2", + "typescript-eslint": "^8.39.1" }, "lint-staged": { "*.ts": [ diff --git a/packages/apps/reputation-oracle/server/src/app.controller.ts b/packages/apps/reputation-oracle/server/src/app.controller.ts index bfe63b0c9c..c69f07cb78 100644 --- a/packages/apps/reputation-oracle/server/src/app.controller.ts +++ b/packages/apps/reputation-oracle/server/src/app.controller.ts @@ -1,5 +1,6 @@ import { Controller, Get, Redirect } from '@nestjs/common'; import { ApiExcludeEndpoint } from '@nestjs/swagger'; + import { Public } from './common/decorators'; @Controller() diff --git a/packages/apps/reputation-oracle/server/src/app.module.ts b/packages/apps/reputation-oracle/server/src/app.module.ts index dbcab17043..a064f1b5c9 100644 --- a/packages/apps/reputation-oracle/server/src/app.module.ts +++ b/packages/apps/reputation-oracle/server/src/app.module.ts @@ -1,31 +1,29 @@ import { ClassSerializerInterceptor, Module } from '@nestjs/common'; -import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core'; import { ConfigModule } from '@nestjs/config'; +import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core'; import { ScheduleModule } from '@nestjs/schedule'; import { AppController } from './app.controller'; -import { JwtAuthGuard } from './common/guards'; import { ExceptionFilter } from './common/filters/exception.filter'; +import { JwtAuthGuard } from './common/guards'; import { TransformInterceptor } from './common/interceptors/transform.interceptor'; import { HttpValidationPipe } from './common/pipes'; import { envValidator, EnvConfigModule } from './config'; import { DatabaseModule } from './database'; - import { AbuseModule } from './modules/abuse'; import { AuthModule } from './modules/auth'; import { CronJobModule } from './modules/cron-job'; import { EscrowCompletionModule } from './modules/escrow-completion'; import { HealthModule } from './modules/health'; -import { - IncomingWebhookModule, - OutgoingWebhookModule, -} from './modules/webhook'; import { KycModule } from './modules/kyc'; import { NDAModule } from './modules/nda'; import { QualificationModule } from './modules/qualification'; import { ReputationModule } from './modules/reputation'; import { UserModule } from './modules/user'; - +import { + IncomingWebhookModule, + OutgoingWebhookModule, +} from './modules/webhook'; import Environment from './utils/environment'; @Module({ diff --git a/packages/apps/reputation-oracle/server/src/common/decorators/index.ts b/packages/apps/reputation-oracle/server/src/common/decorators/index.ts index 1928a9fc7e..93579ac151 100644 --- a/packages/apps/reputation-oracle/server/src/common/decorators/index.ts +++ b/packages/apps/reputation-oracle/server/src/common/decorators/index.ts @@ -1,4 +1,5 @@ import { Reflector } from '@nestjs/core'; + import { UserRole } from '@/modules/user'; /** diff --git a/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts b/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts index 41ddd25626..6f7006a235 100644 --- a/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts +++ b/packages/apps/reputation-oracle/server/src/common/filters/exception.filter.ts @@ -6,6 +6,7 @@ import { HttpException, } from '@nestjs/common'; import { Request, Response } from 'express'; + import { DatabaseError, isDuplicatedError } from '@/database'; import logger from '@/logger'; import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; @@ -14,7 +15,7 @@ import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; export class ExceptionFilter implements IExceptionFilter { private readonly logger = logger.child({ context: ExceptionFilter.name }); - catch(exception: any, host: ArgumentsHost) { + catch(exception: unknown, host: ArgumentsHost) { const ctx = host.switchToHttp(); const response = ctx.getResponse(); const request = ctx.getRequest(); diff --git a/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts index 9b47ceb74e..7ba42c1967 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/jwt.auth.ts @@ -6,6 +6,7 @@ import { } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { AuthGuard } from '@nestjs/passport'; + import { JWT_STRATEGY_NAME } from '@/common/constants'; import { Public } from '@/common/decorators'; @@ -28,6 +29,7 @@ export class JwtAuthGuard extends AuthGuard(JWT_STRATEGY_NAME) { return super.canActivate(context); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any handleRequest(error: any, user: any) { if (error) { /** diff --git a/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts index 50f12e1f27..b5fafb4f27 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts @@ -6,7 +6,10 @@ import { HttpException, } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; + import { Roles } from '@/common/decorators'; +import type { RequestWithUser } from '@/common/types'; +import type { UserRole } from '@/modules/user'; @Injectable() export class RolesAuthGuard implements CanActivate { @@ -28,9 +31,9 @@ export class RolesAuthGuard implements CanActivate { ); } - const { user } = context.switchToHttp().getRequest(); + const { user } = context.switchToHttp().getRequest() as RequestWithUser; - if (allowedRoles.includes(user.role)) { + if (allowedRoles.includes(user.role as UserRole)) { return true; } diff --git a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts index 56803f8a5a..3971dc96d0 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts @@ -1,16 +1,16 @@ jest.mock('@human-protocol/sdk'); import { faker } from '@faker-js/faker'; -import { EscrowUtils } from '@human-protocol/sdk'; +import { EscrowUtils, IEscrow } from '@human-protocol/sdk'; import { ExecutionContext, HttpException, HttpStatus } from '@nestjs/common'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { signMessage } from '@/utils/web3'; import { generateEthWallet } from '~/test/fixtures/web3'; import { createExecutionContextMock, ExecutionContextMock, } from '~/test/mock-creators/nest'; -import { generateTestnetChainId } from '@/modules/web3/fixtures'; -import { signMessage } from '@/utils/web3'; import { AuthSignatureRole, SignatureAuthGuard } from './signature.auth'; @@ -67,7 +67,7 @@ describe('SignatureAuthGuard', () => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ [name]: address, - } as any); + } as unknown as IEscrow); const signature = await signMessage(body, privateKey); @@ -98,7 +98,7 @@ describe('SignatureAuthGuard', () => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: address, - } as any); + } as unknown as IEscrow); const signature = await signMessage( { @@ -138,7 +138,7 @@ describe('SignatureAuthGuard', () => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: address, exchangeOracle: address, - } as any); + } as unknown as IEscrow); const signature = await signMessage(body, privateKey); @@ -176,7 +176,7 @@ describe('SignatureAuthGuard', () => { launcher: '', exchangeOracle: '', recordingOracle: '', - } as any); + } as unknown as IEscrow); const signature = await signMessage(body, privateKey); diff --git a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts index fbf919de90..cdcc5ef1a9 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/signature.auth.ts @@ -6,8 +6,9 @@ import { HttpStatus, Injectable, } from '@nestjs/common'; -import { verifySignature } from '@/utils/web3'; + import { HEADER_SIGNATURE_KEY } from '@/common/constants'; +import { verifySignature } from '@/utils/web3'; export enum AuthSignatureRole { JOB_LAUNCHER = 'job_launcher', @@ -15,6 +16,12 @@ export enum AuthSignatureRole { RECORDING_ORACLE = 'recording', } +type SignedRequestData = { + chain_id?: number; + escrow_address?: string; + [x: string]: unknown; +}; + @Injectable() export class SignatureAuthGuard implements CanActivate { private readonly authorizedSignerRoles: AuthSignatureRole[]; @@ -30,8 +37,16 @@ export class SignatureAuthGuard implements CanActivate { public async canActivate(context: ExecutionContext): Promise { const request = context.switchToHttp().getRequest(); - const data = request.body; - const signature = request.headers[HEADER_SIGNATURE_KEY]; + const data = request.body as SignedRequestData; + if (!data.chain_id || !data.escrow_address) { + throw new HttpException('Invalid payload', HttpStatus.BAD_REQUEST); + } + + const signature: string | undefined = request.headers[HEADER_SIGNATURE_KEY]; + if (!signature) { + throw new HttpException('Missing signature', HttpStatus.BAD_REQUEST); + } + const oracleAdresses: string[] = []; const escrowData = await EscrowUtils.getEscrow( data.chain_id, diff --git a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts index 7f452661d2..1e823b3536 100644 --- a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.spec.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; import { ExecutionContext, StreamableFile } from '@nestjs/common'; import { firstValueFrom, of } from 'rxjs'; -import { TransformInterceptor } from './transform.interceptor'; + import { CallHandlerMock, createCallHandlerMock, @@ -9,6 +9,8 @@ import { ExecutionContextMock, } from '~/test/mock-creators/nest'; +import { TransformInterceptor } from './transform.interceptor'; + describe('TransformInterceptor', () => { describe('intercept', () => { const interceptor = new TransformInterceptor(); diff --git a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts index ceac84ea1b..5408ab7dd1 100644 --- a/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts +++ b/packages/apps/reputation-oracle/server/src/common/interceptors/transform.interceptor.ts @@ -7,11 +7,12 @@ import { } from '@nestjs/common'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; + import * as CaseConverter from '@/utils/case-converters'; @Injectable() export class TransformInterceptor implements NestInterceptor { - intercept(context: ExecutionContext, next: CallHandler): Observable { + intercept(context: ExecutionContext, next: CallHandler): Observable { const request = context.switchToHttp().getRequest(); if (request.body) { diff --git a/packages/apps/reputation-oracle/server/src/common/types/request.ts b/packages/apps/reputation-oracle/server/src/common/types/request.ts index c63d60956d..303e0fe198 100644 --- a/packages/apps/reputation-oracle/server/src/common/types/request.ts +++ b/packages/apps/reputation-oracle/server/src/common/types/request.ts @@ -1,3 +1,3 @@ export interface RequestWithUser extends Request { - user: { id: number }; + user: { id: number; role: string }; } diff --git a/packages/apps/reputation-oracle/server/src/common/validators/password.ts b/packages/apps/reputation-oracle/server/src/common/validators/password.ts index edea4cdd17..13fc8a526e 100644 --- a/packages/apps/reputation-oracle/server/src/common/validators/password.ts +++ b/packages/apps/reputation-oracle/server/src/common/validators/password.ts @@ -53,7 +53,7 @@ export function IsPassword( constraints: Partial = {}, validationOptions?: ValidationOptions, ) { - return (object: Record, propertyName: string): void => { + return (object: Record, propertyName: string): void => { registerDecorator({ name: 'isPassword', target: object.constructor, diff --git a/packages/apps/reputation-oracle/server/src/common/validators/web3.ts b/packages/apps/reputation-oracle/server/src/common/validators/web3.ts index eed8b2be5b..4b74af2c82 100644 --- a/packages/apps/reputation-oracle/server/src/common/validators/web3.ts +++ b/packages/apps/reputation-oracle/server/src/common/validators/web3.ts @@ -16,7 +16,7 @@ export function IsValidWeb3Signature(validationOptions?: ValidationOptions) { propertyName: propertyName, options: validationOptions, validator: { - validate(value: any) { + validate(value: unknown) { if (typeof value !== 'string') { return false; } diff --git a/packages/apps/reputation-oracle/server/src/config/config.module.ts b/packages/apps/reputation-oracle/server/src/config/config.module.ts index 6289b989b3..eb3e0f4af0 100644 --- a/packages/apps/reputation-oracle/server/src/config/config.module.ts +++ b/packages/apps/reputation-oracle/server/src/config/config.module.ts @@ -11,8 +11,8 @@ import { PGPConfigService } from './pgp-config.service'; import { ReputationConfigService } from './reputation-config.service'; import { S3ConfigService } from './s3-config.service'; import { ServerConfigService } from './server-config.service'; -import { Web3ConfigService } from './web3-config.service'; import { SlackConfigService } from './slack-config.service'; +import { Web3ConfigService } from './web3-config.service'; @Global() @Module({ diff --git a/packages/apps/reputation-oracle/server/src/config/env-schema.ts b/packages/apps/reputation-oracle/server/src/config/env-schema.ts index 8b3284f159..0df0b9fd1f 100644 --- a/packages/apps/reputation-oracle/server/src/config/env-schema.ts +++ b/packages/apps/reputation-oracle/server/src/config/env-schema.ts @@ -1,4 +1,5 @@ import * as Joi from 'joi'; + import { Web3Network } from './web3-config.service'; export const envValidator = Joi.object({ diff --git a/packages/apps/reputation-oracle/server/src/database/base.repository.ts b/packages/apps/reputation-oracle/server/src/database/base.repository.ts index 61f5996e08..436edd2956 100644 --- a/packages/apps/reputation-oracle/server/src/database/base.repository.ts +++ b/packages/apps/reputation-oracle/server/src/database/base.repository.ts @@ -1,6 +1,7 @@ import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm'; -import { DatabaseError, handleDbError } from './errors'; + import { BaseEntity } from './base.entity'; +import { DatabaseError, handleDbError } from './errors'; export class BaseRepository< T extends BaseEntity & ObjectLiteral, @@ -17,6 +18,7 @@ export class BaseRepository< await this.insert(item); } catch (error) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw handleDbError(error); } return item; @@ -27,6 +29,7 @@ export class BaseRepository< item.updatedAt = new Date(); await this.save(item); } catch (error) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw handleDbError(error); } return item; @@ -50,6 +53,7 @@ export class BaseRepository< return result.affected > 0; } catch (error) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw handleDbError(error); } } @@ -58,6 +62,7 @@ export class BaseRepository< try { await this.remove(item); } catch (error) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw handleDbError(error); } } diff --git a/packages/apps/reputation-oracle/server/src/database/database.module.ts b/packages/apps/reputation-oracle/server/src/database/database.module.ts index ee4719f1ec..7a77ad51c1 100644 --- a/packages/apps/reputation-oracle/server/src/database/database.module.ts +++ b/packages/apps/reputation-oracle/server/src/database/database.module.ts @@ -4,24 +4,24 @@ import { LoggerOptions } from 'typeorm'; import { SnakeNamingStrategy } from 'typeorm-naming-strategies'; import { DatabaseConfigService } from '@/config'; -import { ReputationEntity } from '@/modules/reputation'; +import { AbuseEntity } from '@/modules/abuse'; import { TokenEntity } from '@/modules/auth'; -import { UserEntity, SiteKeyEntity } from '@/modules/user'; -import { KycEntity } from '@/modules/kyc'; import { CronJobEntity } from '@/modules/cron-job'; +import { + EscrowCompletionEntity, + EscrowPayoutsBatchEntity, +} from '@/modules/escrow-completion'; +import { KycEntity } from '@/modules/kyc'; import { QualificationEntity, UserQualificationEntity, } from '@/modules/qualification'; +import { ReputationEntity } from '@/modules/reputation'; +import { UserEntity, SiteKeyEntity } from '@/modules/user'; import { IncomingWebhookEntity, OutgoingWebhookEntity, } from '@/modules/webhook'; -import { - EscrowCompletionEntity, - EscrowPayoutsBatchEntity, -} from '@/modules/escrow-completion'; -import { AbuseEntity } from '@/modules/abuse'; import { TypeOrmLoggerModule, TypeOrmLoggerService } from './typeorm'; diff --git a/packages/apps/reputation-oracle/server/src/database/errors.ts b/packages/apps/reputation-oracle/server/src/database/errors.ts index e0f5229260..6c3a5fb7c9 100644 --- a/packages/apps/reputation-oracle/server/src/database/errors.ts +++ b/packages/apps/reputation-oracle/server/src/database/errors.ts @@ -10,7 +10,7 @@ export enum DatabaseErrorMessages { DUPLICATED = 'Entity duplication error', } -export function handleDbError(error: any): DatabaseError { +export function handleDbError(error: Error & { code: unknown }): DatabaseError { if (error.code === PostgresErrorCodes.Duplicated) { return new DatabaseError(DatabaseErrorMessages.DUPLICATED); } diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts index d7bf6716b8..327da9f5fc 100644 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts +++ b/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts @@ -1,4 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; + import { DATABASE_SCHEMA_NAME } from '@/common/constants'; export class InitialMigration1752590727473 implements MigrationInterface { diff --git a/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts b/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts index e3d982ac92..5bb673983f 100644 --- a/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts +++ b/packages/apps/reputation-oracle/server/src/database/typeorm/typeorm-logger.service.ts @@ -1,9 +1,10 @@ import * as util from 'util'; + +import { Inject, Injectable, Logger, type LoggerService } from '@nestjs/common'; import { Logger as TypeOrmLogger, LoggerOptions as TypeOrmLoggerOptions, } from 'typeorm'; -import { Inject, Injectable, Logger, type LoggerService } from '@nestjs/common'; @Injectable() export class TypeOrmLoggerService implements TypeOrmLogger { @@ -15,7 +16,7 @@ export class TypeOrmLoggerService implements TypeOrmLogger { this.options = options; } - logQuery(query: string, parameters?: any[]): void { + logQuery(query: string, parameters?: unknown[]): void { if ( this.options === 'all' || this.options === true || @@ -28,7 +29,7 @@ export class TypeOrmLoggerService implements TypeOrmLogger { } } - logQueryError(error: string, query: string, parameters?: any[]): void { + logQueryError(error: string, query: string, parameters?: unknown[]): void { if ( this.options === 'all' || this.options === true || @@ -42,7 +43,7 @@ export class TypeOrmLoggerService implements TypeOrmLogger { } } - logQuerySlow(time: number, query: string, parameters?: any[]): void { + logQuerySlow(time: number, query: string, parameters?: unknown[]): void { this.loggerService.log( `query is slow: ${query} ${this.stringifyParams(parameters)}`, 'TypeOrm', @@ -89,7 +90,7 @@ export class TypeOrmLoggerService implements TypeOrmLogger { } } - protected stringifyParams(parameters: any[] = []): string { + protected stringifyParams(parameters: unknown[] = []): string { return parameters.length ? ` -- PARAMETERS: ${util.inspect(parameters)}` : ''; diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts index 20d94715ed..57816f3c56 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/fixtures/index.ts @@ -1,4 +1,5 @@ import { faker } from '@faker-js/faker'; + import { HCaptchaConfigService } from '@/config'; export const mockHCaptchaConfigService: Omit< diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.ts index 27bbc93d76..1b6c71e38a 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.guard.ts @@ -6,6 +6,7 @@ import { HttpException, } from '@nestjs/common'; import { Request } from 'express'; + import { HCaptchaService } from './hcaptcha.service'; @Injectable() @@ -20,7 +21,7 @@ export class HCaptchaGuard implements CanActivate { * Guards called before interceptors, * so we need to access body params as is */ - const hCaptchaToken = body['h_captcha_token']; + const hCaptchaToken: string = body['h_captcha_token']; if (!hCaptchaToken) { throw new HttpException( 'hCaptcha token not provided', diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.module.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.module.ts index 92d8dceb26..b105d69e6e 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.module.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.module.ts @@ -1,5 +1,6 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; + import { HCaptchaService } from './hcaptcha.service'; @Module({ diff --git a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts index 0024970326..67acfe1d2e 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/hcaptcha/hcaptcha.service.spec.ts @@ -3,17 +3,16 @@ import { HttpService } from '@nestjs/axios'; import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; -import { HCaptchaService } from './hcaptcha.service'; import { HCaptchaConfigService } from '@/config'; - +import { generateEthWallet } from '~/test/fixtures/web3'; import { createHttpServiceMock, createHttpServiceRequestError, createHttpServiceResponse, } from '~/test/mock-creators/nest'; -import { generateEthWallet } from '~/test/fixtures/web3'; import { mockHCaptchaConfigService } from './fixtures'; +import { HCaptchaService } from './hcaptcha.service'; import { LabelerData, SiteverifyResponse } from './types'; const mockHttpService = createHttpServiceMock(); diff --git a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts index d03afc2179..77ef4163f6 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.spec.ts @@ -1,12 +1,15 @@ -import { HttpService } from '@nestjs/axios'; -import { SlackBotApp } from './slack-bot-app'; import { faker } from '@faker-js/faker'; +import { HttpService } from '@nestjs/axios'; +import type { View } from '@slack/web-api'; + import { createHttpServiceMock, createHttpServiceRequestError, createHttpServiceResponse, } from '~/test/mock-creators/nest'; +import { SlackBotApp } from './slack-bot-app'; + const mockHttpService = createHttpServiceMock(); describe('SlackBotApp', () => { @@ -62,9 +65,10 @@ describe('SlackBotApp', () => { ); const triggerId = faker.word.sample(); - const modalView: any = { + const modalView: View = { type: 'modal', title: { type: 'plain_text', text: 'Test' }, + blocks: [], }; await expect( @@ -95,9 +99,10 @@ describe('SlackBotApp', () => { ); const triggerId = faker.word.sample(); - const modalView: any = { + const modalView: View = { type: 'modal', title: { type: 'plain_text', text: 'Test' }, + blocks: [], }; await expect(slackBotApp.openModal(triggerId, modalView)).rejects.toThrow( diff --git a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts index c38296f87e..86c3d301c0 100644 --- a/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts +++ b/packages/apps/reputation-oracle/server/src/integrations/slack-bot-app/slack-bot-app.ts @@ -1,7 +1,9 @@ import { HttpService } from '@nestjs/axios'; -import { View, ViewsOpenResponse } from '@slack/web-api'; +import type { View, ViewsOpenResponse } from '@slack/web-api'; import { IncomingWebhookSendArguments } from '@slack/webhook'; +import { AxiosError } from 'axios'; import { firstValueFrom } from 'rxjs'; + import logger from '@/logger'; import * as httpUtils from '@/utils/http'; @@ -18,7 +20,10 @@ export class SlackBotApp { this.httpService.post(this.config.webhookUrl, message), ); } catch (error) { - const formattedError = httpUtils.formatAxiosError(error); + let formattedError = error; + if (error instanceof AxiosError) { + formattedError = httpUtils.formatAxiosError(error); + } const errorMessage = 'Error sending Slack notification'; this.logger.error(errorMessage, { error: formattedError, @@ -50,7 +55,10 @@ export class SlackBotApp { throw new Error('Error opening Slack modal'); } } catch (error) { - const formattedError = httpUtils.formatAxiosError(error); + let formattedError = error; + if (error instanceof AxiosError) { + formattedError = httpUtils.formatAxiosError(error); + } const errorMessage = 'Error opening Slack modal'; this.logger.error(errorMessage, { error: formattedError, @@ -63,7 +71,10 @@ export class SlackBotApp { try { await firstValueFrom(this.httpService.post(responseUrl, { text })); } catch (error) { - const formattedError = httpUtils.formatAxiosError(error); + let formattedError = error; + if (error instanceof AxiosError) { + formattedError = httpUtils.formatAxiosError(error); + } const errorMessage = 'Error updating Slack message'; this.logger.error(errorMessage, { error: formattedError, diff --git a/packages/apps/reputation-oracle/server/src/main.ts b/packages/apps/reputation-oracle/server/src/main.ts index 62c688a44b..aa15e030f9 100644 --- a/packages/apps/reputation-oracle/server/src/main.ts +++ b/packages/apps/reputation-oracle/server/src/main.ts @@ -1,18 +1,20 @@ +import { IncomingMessage, ServerResponse } from 'http'; + import { INestApplication } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { json, urlencoded } from 'body-parser'; import { useContainer } from 'class-validator'; +import type { Request } from 'express'; import helmet from 'helmet'; -import { IncomingMessage, ServerResponse } from 'http'; import { AppModule } from './app.module'; import { ServerConfigService } from './config'; import logger, { nestLoggerOverride } from './logger'; function rawBodyMiddleware( - req: any, + req: Request & { rawBody?: string }, _res: ServerResponse, buf: Buffer, ): void { diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts index b9762aeced..7abc0713a8 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.spec.ts @@ -1,9 +1,9 @@ import { faker } from '@faker-js/faker'; -import { Test } from '@nestjs/testing'; import { HttpService } from '@nestjs/axios'; +import { Test } from '@nestjs/testing'; -import { createHttpServiceMock } from '~/test/mock-creators/nest'; import { SlackConfigService } from '@/config'; +import { createHttpServiceMock } from '~/test/mock-creators/nest'; import { AbuseSlackBot } from './abuse-slack-bot'; import { AbuseDecision } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts index 041663c78a..64e18495b2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse-slack-bot.ts @@ -6,7 +6,9 @@ import { IncomingWebhookSendArguments } from '@slack/webhook'; import { SlackConfigService } from '@/config'; import { SlackBotApp } from '@/integrations/slack-bot-app'; + import { AbuseDecision } from './constants'; +import { AbuseReportModalPrivateMetadata } from './types'; @Injectable() export class AbuseSlackBot extends SlackBotApp { @@ -79,11 +81,15 @@ export class AbuseSlackBot extends SlackBotApp { triggerId: string; responseUrl: string; }): Promise { + const privateMetadata: AbuseReportModalPrivateMetadata = { + responseUrl: data.responseUrl, + }; + const modalView: View = { type: 'modal', callback_id: `${data.abuseId}`, title: { type: 'plain_text', text: 'Confirm slash' }, - private_metadata: JSON.stringify({ responseUrl: data.responseUrl }), + private_metadata: JSON.stringify(privateMetadata), blocks: [ { type: 'section', diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts index bdba6d269a..0212fd9fcc 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.controller.ts @@ -18,14 +18,15 @@ import { import { Public } from '@/common/decorators'; import type { RequestWithUser } from '@/common/types'; +import { AbuseSlackAuthGuard } from './abuse-slack-auth.guard'; import { AbuseResponseDto, ReportAbuseDto, SlackInteractionDto, } from './abuse.dto'; -import { AbuseService } from './abuse.service'; import { AbuseRepository } from './abuse.repository'; -import { AbuseSlackAuthGuard } from './abuse-slack-auth.guard'; +import { AbuseService } from './abuse.service'; +import type { SlackInteraction } from './types'; @ApiTags('Abuse') @Controller('/abuse') @@ -104,6 +105,8 @@ export class AbuseController { async receiveInteractions( @Body() data: SlackInteractionDto, ): Promise { - return this.abuseService.processSlackInteraction(JSON.parse(data.payload)); + return this.abuseService.processSlackInteraction( + JSON.parse(data.payload) as SlackInteraction, + ); } } diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts index b5b1337db8..a7b64f3309 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.dto.ts @@ -3,6 +3,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsEthereumAddress, IsString, MaxLength } from 'class-validator'; import { IsChainId } from '@/common/validators'; + import { AbuseStatus } from './constants'; export class ReportAbuseDto { diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts index 7b7c7f974e..8c47706f2f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.entity.ts @@ -4,6 +4,7 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; import type { UserEntity } from '@/modules/user'; + import { AbuseDecision, AbuseStatus } from './constants'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'abuses' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts index f0c6c7e2da..c665760bcd 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.module.ts @@ -1,5 +1,5 @@ -import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; +import { Module } from '@nestjs/common'; import { Web3Module } from '@/modules/web3'; import { OutgoingWebhookModule } from '@/modules/webhook'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts index 38eb73571f..e7c441672a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.repository.ts @@ -9,6 +9,7 @@ import { import { ServerConfigService } from '@/config'; import { BaseRepository } from '@/database'; + import { AbuseEntity } from './abuse.entity'; import { AbuseStatus } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts index bc33725cfe..5d53b01ffe 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.spec.ts @@ -4,26 +4,29 @@ import { faker } from '@faker-js/faker'; import { createMock } from '@golevelup/ts-jest'; import { EscrowUtils, + IEscrow, IOperator, OperatorUtils, StakingClient, } from '@human-protocol/sdk'; import { ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; -import { DatabaseError, DatabaseErrorMessages } from '@/database'; + import { ServerConfigService } from '@/config'; -import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { DatabaseError, DatabaseErrorMessages } from '@/database'; import { Web3Service } from '@/modules/web3'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { OutgoingWebhookEventType, OutgoingWebhookService, } from '@/modules/webhook'; +import { AbuseSlackBot } from './abuse-slack-bot'; import { AbuseRepository } from './abuse.repository'; import { AbuseService } from './abuse.service'; -import { AbuseSlackBot } from './abuse-slack-bot'; import { AbuseDecision, AbuseStatus } from './constants'; import { generateAbuseEntity } from './fixtures'; +import { SlackInteraction } from './types'; const fakeAddress = faker.finance.ethereumAddress(); @@ -103,7 +106,6 @@ describe('AbuseService', () => { const dto = { callback_id: abuseEntity.id, - chainId, type: 'interactive_message', actions: [{ value: AbuseDecision.ACCEPTED }], trigger_id: faker.string.uuid(), @@ -113,13 +115,15 @@ describe('AbuseService', () => { mockAbuseRepository.findOneById.mockResolvedValueOnce(abuseEntity); mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: fakeAddress, - } as any); + } as unknown as IEscrow); const amount = faker.number.int(); mockedOperatorUtils.getOperator.mockResolvedValueOnce({ amountStaked: BigInt(amount), } as IOperator); - await abuseService.processSlackInteraction(dto as any); + await abuseService.processSlackInteraction( + dto as unknown as SlackInteraction, + ); expect(mockAbuseSlackBot.triggerAbuseReportModal).toHaveBeenCalledTimes( 1, @@ -155,7 +159,9 @@ describe('AbuseService', () => { mockAbuseRepository.findOneById.mockResolvedValueOnce(abuseEntity); - await abuseService.processSlackInteraction(dto as any); + await abuseService.processSlackInteraction( + dto as unknown as SlackInteraction, + ); expect(mockAbuseSlackBot.updateMessage).toHaveBeenCalledTimes(1); expect(mockAbuseSlackBot.updateMessage).toHaveBeenCalledWith( @@ -182,7 +188,9 @@ describe('AbuseService', () => { mockAbuseRepository.findOneById.mockResolvedValueOnce(abuseEntity); - await abuseService.processSlackInteraction(dto as any); + await abuseService.processSlackInteraction( + dto as unknown as SlackInteraction, + ); expect(mockAbuseRepository.updateOne).toHaveBeenCalledWith({ ...abuseEntity, @@ -202,7 +210,9 @@ describe('AbuseService', () => { mockAbuseRepository.findOneById.mockResolvedValueOnce(null); await expect( - abuseService.processSlackInteraction(dto as any), + abuseService.processSlackInteraction( + dto as unknown as SlackInteraction, + ), ).rejects.toThrow('Abuse entity not found'); }); @@ -216,7 +226,9 @@ describe('AbuseService', () => { mockAbuseRepository.findOneById.mockResolvedValueOnce(null); await expect( - abuseService.processSlackInteraction(dto as any), + abuseService.processSlackInteraction( + dto as unknown as SlackInteraction, + ), ).rejects.toThrow( 'Callback ID is missing from the Slack interaction data', ); @@ -233,10 +245,10 @@ describe('AbuseService', () => { mockedEscrowUtils.getEscrow .mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any) + } as unknown as IEscrow) .mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any); + } as unknown as IEscrow); mockedOperatorUtils.getOperator .mockResolvedValueOnce({ webhookUrl: webhookUrl1, @@ -267,7 +279,7 @@ describe('AbuseService', () => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any); + } as unknown as IEscrow); mockedOperatorUtils.getOperator.mockResolvedValueOnce({ webhookUrl: webhookUrl1, } as IOperator); @@ -296,7 +308,7 @@ describe('AbuseService', () => { ); mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any); + } as unknown as IEscrow); mockedOperatorUtils.getOperator.mockResolvedValueOnce({ webhookUrl: webhookUrl1, } as IOperator); @@ -323,10 +335,10 @@ describe('AbuseService', () => { mockedEscrowUtils.getEscrow .mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any) + } as unknown as IEscrow) .mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any); + } as unknown as IEscrow); mockedOperatorUtils.getOperator .mockResolvedValueOnce({ webhookUrl: webhookUrl1, @@ -395,7 +407,7 @@ describe('AbuseService', () => { } as unknown as StakingClient); mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: fakeAddress, - } as any); + } as unknown as IEscrow); mockedOperatorUtils.getOperator.mockResolvedValueOnce({ webhookUrl: webhookUrl1, } as IOperator); @@ -439,7 +451,7 @@ describe('AbuseService', () => { ); mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ exchangeOracle: fakeAddress, - } as any); + } as unknown as IEscrow); mockedOperatorUtils.getOperator.mockResolvedValueOnce({ webhookUrl: webhookUrl1, } as IOperator); diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts index 73143a3bf9..aa59525880 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/abuse.service.ts @@ -6,8 +6,9 @@ import { } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { ethers } from 'ethers'; -import { isDuplicatedError } from '@/database'; + import { ServerConfigService } from '@/config'; +import { isDuplicatedError } from '@/database'; import logger from '@/logger'; import { Web3Service } from '@/modules/web3'; import { @@ -15,16 +16,17 @@ import { OutgoingWebhookService, } from '@/modules/webhook'; +import { AbuseSlackBot } from './abuse-slack-bot'; import { AbuseEntity } from './abuse.entity'; import { AbuseRepository } from './abuse.repository'; import { AbuseDecision, AbuseStatus } from './constants'; import { + AbuseReportModalPrivateMetadata, isInteractiveMessage, isViewSubmission, ReportAbuseInput, SlackInteraction, } from './types'; -import { AbuseSlackBot } from './abuse-slack-bot'; @Injectable() export class AbuseService { @@ -116,7 +118,10 @@ export class AbuseService { }); return ''; } else if (isViewSubmission(data)) { - const privateMetadata = JSON.parse(data.view.private_metadata); + const privateMetadata = JSON.parse( + data.view.private_metadata, + ) as AbuseReportModalPrivateMetadata; + const responseUrl = privateMetadata.responseUrl; abuseEntity.decision = AbuseDecision.ACCEPTED; abuseEntity.amount = data.view.state.values.quantity_input.quantity.value; diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts index 1807919893..2999284bb1 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/fixtures/index.ts @@ -1,10 +1,10 @@ import { faker } from '@faker-js/faker'; -import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { generateWorkerUser } from '@/modules/user/fixtures'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; -import { AbuseStatus } from '../constants'; import { AbuseEntity } from '../abuse.entity'; +import { AbuseStatus } from '../constants'; export function generateAbuseEntity( overrides?: Partial, diff --git a/packages/apps/reputation-oracle/server/src/modules/abuse/types.ts b/packages/apps/reputation-oracle/server/src/modules/abuse/types.ts index 37dec9605c..d0978aa3a2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/abuse/types.ts +++ b/packages/apps/reputation-oracle/server/src/modules/abuse/types.ts @@ -82,3 +82,7 @@ export function isViewSubmission( ): data is ViewSubmission { return data.type === 'view_submission'; } + +export type AbuseReportModalPrivateMetadata = { + responseUrl: string; +}; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts index 04e27ac2fc..1ed11efd07 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.controller.ts @@ -1,11 +1,3 @@ -import { - ApiOperation, - ApiResponse, - ApiTags, - ApiBody, - ApiBearerAuth, - ApiHeader, -} from '@nestjs/swagger'; import { Body, ClassSerializerInterceptor, @@ -18,13 +10,21 @@ import { HttpCode, Headers, } from '@nestjs/common'; +import { + ApiOperation, + ApiResponse, + ApiTags, + ApiBody, + ApiBearerAuth, + ApiHeader, +} from '@nestjs/swagger'; import { Public } from '@/common/decorators'; import type { RequestWithUser } from '@/common/types'; import { HCaptchaGuard } from '@/integrations/hcaptcha/hcaptcha.guard'; -import { AuthService } from './auth.service'; import { AuthControllerErrorsFilter } from './auth.error-filter'; +import { AuthService } from './auth.service'; import { HEADER_M2M_AUTH } from './constants'; import { ForgotPasswordDto, @@ -39,8 +39,8 @@ import { Web3SignUpDto, SuccessM2mAuthDto, } from './dto'; -import { TokenRepository } from './token.repository'; import { TokenType } from './token.entity'; +import { TokenRepository } from './token.repository'; @ApiTags('Auth') @Controller('/auth') diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts index 3e63e430bc..78d46ee8f8 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts @@ -7,8 +7,6 @@ import { JwtModule, JwtService } from '@nestjs/jwt'; import { Test } from '@nestjs/testing'; import { omit } from 'lodash'; -import { generateES256Keys } from '~/test/fixtures/crypto'; -import { generateEthWallet } from '~/test/fixtures/web3'; import { SignatureType } from '@/common/enums'; import { AuthConfigService, @@ -16,10 +14,8 @@ import { ServerConfigService, Web3ConfigService, } from '@/config'; -import * as secutiryUtils from '@/utils/security'; -import { SiteKeyRepository } from '@/modules/user'; -import * as web3Utils from '@/utils/web3'; import { EmailAction, EmailService } from '@/modules/email'; +import { SiteKeyRepository } from '@/modules/user'; import { UserStatus, UserRole, @@ -29,6 +25,11 @@ import { } from '@/modules/user'; import { generateOperator, generateWorkerUser } from '@/modules/user/fixtures'; import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; +import * as secutiryUtils from '@/utils/security'; +import * as web3Utils from '@/utils/web3'; +import { generateES256Keys } from '~/test/fixtures/crypto'; +import { generateEthWallet } from '~/test/fixtures/web3'; + import * as AuthErrors from './auth.error'; import { AuthService } from './auth.service'; import { TokenEntity, TokenType } from './token.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts index 20bafde940..cc84a67903 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts @@ -10,10 +10,6 @@ import { Web3ConfigService, } from '@/config'; import logger from '@/logger'; -import * as httpUtils from '@/utils/http'; -import * as securityUtils from '@/utils/security'; -import * as web3Utils from '@/utils/web3'; - import { EmailAction, EmailService } from '@/modules/email'; import { OperatorStatus, @@ -27,6 +23,9 @@ import { type OperatorUserEntity, type Web2UserEntity, } from '@/modules/user'; +import * as httpUtils from '@/utils/http'; +import * as securityUtils from '@/utils/security'; +import * as web3Utils from '@/utils/web3'; import { AuthError, @@ -115,7 +114,9 @@ export class AuthService { let role = ''; try { role = await KVStoreUtils.get(chainId, address, KVStoreKeys.role); - } catch (noop) {} + } catch { + // noop + } // We need to exclude ReputationOracle role const isValidRole = [ @@ -131,7 +132,9 @@ export class AuthService { let fee = ''; try { fee = await KVStoreUtils.get(chainId, address, KVStoreKeys.fee); - } catch (noop) {} + } catch { + // noop + } if (!fee) { throw new InvalidOperatorFeeError(fee); } @@ -139,7 +142,9 @@ export class AuthService { let url = ''; try { url = await KVStoreUtils.get(chainId, address, KVStoreKeys.url); - } catch (noop) {} + } catch { + // noop + } if (!url || !httpUtils.isValidHttpUrl(url)) { throw new InvalidOperatorUrlError(url); } @@ -276,7 +281,9 @@ export class AuthService { this.web3ConfigService.operatorAddress, userEntity.evmAddress, )) as OperatorStatus; - } catch (noop) {} + } catch { + // noop + } const jwtPayload = { status: userEntity.status, diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts index 0aceb25678..0059c952de 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts @@ -7,6 +7,7 @@ import { IsValidWeb3Signature, } from '@/common/validators'; import { UserRole } from '@/modules/user'; + import { ValidPassword } from './password.dto'; export class Web2SignUpDto { diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts b/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts index a40f595dfe..217c128ca2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts @@ -1,14 +1,15 @@ -import { ExtractJwt, Strategy } from 'passport-jwt'; -import { PassportStrategy } from '@nestjs/passport'; import { Injectable, Req, UnauthorizedException } from '@nestjs/common'; +import { PassportStrategy } from '@nestjs/passport'; +import type { Request } from 'express'; +import { ExtractJwt, Strategy } from 'passport-jwt'; import { JWT_STRATEGY_NAME, LOGOUT_PATH, RESEND_EMAIL_VERIFICATION_PATH, } from '@/common/constants'; -import { UserRole, UserStatus } from '@/modules/user'; import { AuthConfigService } from '@/config'; +import { UserRole, UserStatus } from '@/modules/user'; @Injectable() export class JwtHttpStrategy extends PassportStrategy( @@ -25,7 +26,7 @@ export class JwtHttpStrategy extends PassportStrategy( } async validate( - @Req() request: any, + @Req() request: Request, payload: { user_id: number; status: UserStatus; role: UserRole }, ): Promise<{ id: number; role: UserRole }> { if ( diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts b/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts index 28cddc786a..26980ecbb2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/token.entity.ts @@ -7,9 +7,9 @@ import { ManyToOne, } from 'typeorm'; -import type { UserEntity } from '@/modules/user'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; +import type { UserEntity } from '@/modules/user'; export enum TokenType { EMAIL = 'email', diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts b/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts index 95fca6ddbd..f9f03b9ddf 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/token.repository.ts @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, LessThan } from 'typeorm'; import { BaseRepository } from '@/database'; + import { TokenEntity, TokenType } from './token.entity'; type FindOptions = { diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts index d3f5d8c06c..b45744f440 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.module.ts @@ -8,8 +8,8 @@ import { OutgoingWebhookModule, } from '@/modules/webhook'; -import { CronJobService } from './cron-job.service'; import { CronJobRepository } from './cron-job.repository'; +import { CronJobService } from './cron-job.service'; @Module({ imports: [ diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts index 4787b32913..421db2d8df 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.spec.ts @@ -281,6 +281,7 @@ describe('CronJobService', () => { it('should skip processing if a cron job is already running', async () => { spyOnIsCronJobRunning.mockResolvedValueOnce(true); + // eslint-disable-next-line @typescript-eslint/no-explicit-any await (service as any)[method](); expect(spyOnIsCronJobRunning).toHaveBeenCalledTimes(1); @@ -294,6 +295,7 @@ describe('CronJobService', () => { spyOnIsCronJobRunning.mockResolvedValueOnce(false); spyOnStartCronJob.mockResolvedValueOnce(cronJob); + // eslint-disable-next-line @typescript-eslint/no-explicit-any await (service as any)[method](); expect(service.startCronJob).toHaveBeenCalledTimes(1); @@ -311,6 +313,7 @@ describe('CronJobService', () => { processorMock.mockRejectedValueOnce(new Error(faker.lorem.sentence())); + // eslint-disable-next-line @typescript-eslint/no-explicit-any await (service as any)[method](); expect(service.completeCronJob).toHaveBeenCalledTimes(1); diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts index 3ac4d2cc65..660f0b9d11 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/cron-job.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@nestjs/common'; import { Cron } from '@nestjs/schedule'; import logger from '@/logger'; - import { AbuseService } from '@/modules/abuse'; import { TokenRepository } from '@/modules/auth'; import { EscrowCompletionService } from '@/modules/escrow-completion'; diff --git a/packages/apps/reputation-oracle/server/src/modules/cron-job/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/cron-job/fixtures/index.ts index 8e41dcf57b..26c3e2a87c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/cron-job/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/cron-job/fixtures/index.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; -import { CronJobEntity } from '../cron-job.entity'; import { CronJobType } from '../constants'; +import { CronJobEntity } from '../cron-job.entity'; const cronJobTypes = Object.values(CronJobType); diff --git a/packages/apps/reputation-oracle/server/src/modules/email/email.module.ts b/packages/apps/reputation-oracle/server/src/modules/email/email.module.ts index 8df8c3140e..2975f6349b 100644 --- a/packages/apps/reputation-oracle/server/src/modules/email/email.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/email/email.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { MailService } from '@sendgrid/mail'; -import { SendgridEmailService } from './sendgrid.service'; import { EmailService } from './email.service'; +import { SendgridEmailService } from './sendgrid.service'; @Module({ providers: [ diff --git a/packages/apps/reputation-oracle/server/src/modules/email/email.service.ts b/packages/apps/reputation-oracle/server/src/modules/email/email.service.ts index 086cf26af8..a9f0f433d4 100644 --- a/packages/apps/reputation-oracle/server/src/modules/email/email.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/email/email.service.ts @@ -4,6 +4,6 @@ export abstract class EmailService { abstract sendEmail( to: string, action: EmailAction, - payload?: Record, + payload?: Record, ): Promise; } diff --git a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts index ef7e49fecf..da13436c3e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.spec.ts @@ -1,12 +1,14 @@ jest.mock('@/logger'); import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { MailService } from '@sendgrid/mail'; import { EmailConfigService } from '@/config'; import logger from '@/logger'; import Environment from '@/utils/environment'; + import { EmailAction } from './constants'; import { getTemplateId, @@ -15,12 +17,9 @@ import { SERVICE_NAME, } from './sendgrid.service'; -const mockMailService = { - setApiKey: jest.fn(), - send: jest.fn(), -}; +const mockMailService = createMock(); -const mockEmailConfigService = { +const mockEmailConfigService: Omit = { apiKey: `SG.${faker.string.alphanumeric(22)}.${faker.string.alphanumeric(43)}`, from: faker.internet.email(), fromName: faker.string.alpha(), @@ -52,8 +51,8 @@ describe('SendgridEmailService', () => { describe('Initialization', () => { it('should initialize and set API key in staging/production mode', () => { new SendgridEmailService( - mockMailService as any, - mockEmailConfigService as any, + mockMailService, + mockEmailConfigService as EmailConfigService, ); expect(mockMailService.setApiKey).toHaveBeenCalledWith( mockEmailConfigService.apiKey, @@ -68,8 +67,8 @@ describe('SendgridEmailService', () => { expect( () => new SendgridEmailService( - mockMailService as any, - invalidConfig as any, + mockMailService, + invalidConfig as EmailConfigService, ), ).toThrow('Invalid SendGrid API key'); }); diff --git a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts index 4036e923a1..dabd1202fc 100644 --- a/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/email/sendgrid.service.ts @@ -4,6 +4,7 @@ import { MailService } from '@sendgrid/mail'; import { EmailConfigService } from '@/config'; import logger from '@/logger'; import Environment from '@/utils/environment'; + import { EmailAction, SENDGRID_API_KEY_REGEX } from './constants'; import { EmailService } from './email.service'; @@ -46,7 +47,7 @@ export class SendgridEmailService extends EmailService { async sendEmail( to: string, action: EmailAction, - payload?: Record, + payload?: Record, ): Promise { if (Environment.isDevelopment()) { /** diff --git a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts index 34e08a08c2..f83cb9a430 100644 --- a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.spec.ts @@ -15,11 +15,11 @@ import { Encryption, EncryptionUtils, KVStoreUtils } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; import { PGPConfigService, Web3ConfigService } from '@/config'; +import { Web3Service } from '@/modules/web3'; import { generateTestnetChainId, mockWeb3ConfigService, } from '@/modules/web3/fixtures'; -import { Web3Service } from '@/modules/web3'; import { PgpEncryptionService } from './pgp-encryption.service'; @@ -113,10 +113,12 @@ describe('PgpEncryptionService', () => { beforeAll(() => { originalConfigValue = mockPgpConfigService.encrypt; + // eslint-disable-next-line @typescript-eslint/no-explicit-any (mockPgpConfigService as any).encrypt = false; }); afterAll(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (mockPgpConfigService as any).encrypt = originalConfigValue; }); @@ -141,10 +143,12 @@ describe('PgpEncryptionService', () => { beforeAll(() => { originalConfigValue = mockPgpConfigService.encrypt; + // eslint-disable-next-line @typescript-eslint/no-explicit-any (mockPgpConfigService as any).encrypt = true; }); afterAll(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (mockPgpConfigService as any).encrypt = originalConfigValue; }); diff --git a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts index dd22a4e04c..2e15dd9762 100644 --- a/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/encryption/pgp-encryption.service.ts @@ -8,7 +8,6 @@ import { Injectable, OnModuleInit } from '@nestjs/common'; import { PGPConfigService } from '@/config'; import logger from '@/logger'; - import { Web3Service } from '@/modules/web3'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts index fe9eca1ed9..e7eefe54b3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts @@ -3,15 +3,14 @@ import { Module } from '@nestjs/common'; import { ReputationModule } from '@/modules/reputation'; import { StorageModule } from '@/modules/storage'; import { Web3Module } from '@/modules/web3'; - // Using direct import instead of using index.ts due to the circular dependency import { OutgoingWebhookModule } from '@/modules/webhook/webhook-outgoing.module'; import { EscrowCompletionRepository } from './escrow-completion.repository'; import { EscrowCompletionService } from './escrow-completion.service'; import { EscrowPayoutsBatchRepository } from './escrow-payouts-batch.repository'; -import { EscrowResultsProcessingModule } from './results-processing/module'; import { EscrowPayoutsCalculationModule } from './payouts-calculation/module'; +import { EscrowResultsProcessingModule } from './results-processing/module'; @Module({ imports: [ diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts index dff971ab5e..43ecbd48a6 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts @@ -9,49 +9,50 @@ jest.mock('@human-protocol/sdk', () => { }; }); +import * as crypto from 'crypto'; + import { faker } from '@faker-js/faker'; import { createMock } from '@golevelup/ts-jest'; import { EscrowClient, EscrowStatus, EscrowUtils, + IEscrow, + IOperator, OperatorUtils, } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; -import * as crypto from 'crypto'; import stringify from 'json-stable-stringify'; import _ from 'lodash'; -import { createSignerMock, type SignerMock } from '~/test/fixtures/web3'; - import { CvatJobType, FortuneJobType } from '@/common/enums'; import { ServerConfigService } from '@/config'; - import { ReputationService } from '@/modules/reputation'; import { StorageService } from '@/modules/storage'; -import { OutgoingWebhookService } from '@/modules/webhook'; import { WalletWithProvider, Web3Service } from '@/modules/web3'; import { generateTestnetChainId } from '@/modules/web3/fixtures'; +import { OutgoingWebhookService } from '@/modules/webhook'; +import { createSignerMock, type SignerMock } from '~/test/fixtures/web3'; import { EscrowCompletionStatus } from './constants'; +import { EscrowCompletionRepository } from './escrow-completion.repository'; +import { EscrowCompletionService } from './escrow-completion.service'; +import { EscrowPayoutsBatchRepository } from './escrow-payouts-batch.repository'; +import { generateFortuneManifest } from './fixtures'; import { generateEscrowCompletion, generateEscrowPayoutsBatch, } from './fixtures/escrow-completion'; -import { EscrowCompletionService } from './escrow-completion.service'; -import { EscrowCompletionRepository } from './escrow-completion.repository'; -import { EscrowPayoutsBatchRepository } from './escrow-payouts-batch.repository'; -import { - AudinoResultsProcessor, - CvatResultsProcessor, - FortuneResultsProcessor, -} from './results-processing'; import { AudinoPayoutsCalculator, CvatPayoutsCalculator, FortunePayoutsCalculator, } from './payouts-calculation'; -import { generateFortuneManifest } from './fixtures'; +import { + AudinoResultsProcessor, + CvatResultsProcessor, + FortuneResultsProcessor, +} from './results-processing'; const mockServerConfigService = { maxRetryCount: faker.number.int({ min: 2, max: 5 }), @@ -175,6 +176,7 @@ describe('EscrowCompletionService', () => { beforeAll(() => { spyOnCreateEscrowPayoutsBatch = jest + // eslint-disable-next-line @typescript-eslint/no-explicit-any .spyOn(service as any, 'createEscrowPayoutsBatch') .mockImplementation(); }); @@ -313,7 +315,7 @@ describe('EscrowCompletionService', () => { const manifestUrl = faker.internet.url(); mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ manifest: manifestUrl, - } as any); + } as unknown as IEscrow); const fortuneManifest = generateFortuneManifest(); mockStorageService.downloadJsonLikeData.mockResolvedValueOnce( @@ -394,7 +396,9 @@ describe('EscrowCompletionService', () => { }, ]); mockGetEscrowStatus.mockResolvedValue(EscrowStatus.Pending); - mockedEscrowUtils.getEscrow.mockResolvedValueOnce({} as any); + mockedEscrowUtils.getEscrow.mockResolvedValueOnce( + {} as unknown as IEscrow, + ); mockStorageService.downloadJsonLikeData.mockResolvedValueOnce( generateFortuneManifest(), ); @@ -488,6 +492,7 @@ describe('EscrowCompletionService', () => { beforeAll(() => { spyOnProcessPayoutsBatch = jest + // eslint-disable-next-line @typescript-eslint/no-explicit-any .spyOn(service as any, 'processPayoutsBatch') .mockImplementation(); }); @@ -731,6 +736,7 @@ describe('EscrowCompletionService', () => { const payoutsBatch = generateEscrowPayoutsBatch(); const testError = new Error('Synthetic error'); + // eslint-disable-next-line @typescript-eslint/no-explicit-any (testError as any).code = 'NONCE_EXPIRED'; mockedSigner.sendTransaction.mockRejectedValueOnce(testError); @@ -823,7 +829,7 @@ describe('EscrowCompletionService', () => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: launcherAddress, exchangeOracle: exchangeOracleAddress, - } as any); + } as unknown as IEscrow); }); describe('handle failures', () => { @@ -921,7 +927,7 @@ describe('EscrowCompletionService', () => { mockGetEscrowStatus.mockResolvedValueOnce(EscrowStatus.Paid); mockedOperatorUtils.getOperator.mockResolvedValue({ webhookUrl: '', - } as any); + } as IOperator); await service.processPaidEscrows(); @@ -948,7 +954,7 @@ describe('EscrowCompletionService', () => { mockGetEscrowStatus.mockResolvedValueOnce(EscrowStatus.Paid); mockedOperatorUtils.getOperator.mockResolvedValue({ webhookUrl: faker.internet.url(), - } as any); + } as IOperator); mockOutgoingWebhookService.createOutgoingWebhook.mockRejectedValueOnce( testError, ); @@ -1000,7 +1006,7 @@ describe('EscrowCompletionService', () => { webhookUrl = faker.internet.url(); break; } - return { webhookUrl } as any; + return { webhookUrl } as IOperator; }, ); @@ -1064,7 +1070,7 @@ describe('EscrowCompletionService', () => { mockedOperatorUtils.getOperator.mockResolvedValue({ webhookUrl: faker.internet.url(), - } as any); + } as IOperator); await service.processPaidEscrows(); diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts index bf580a8e21..255c875d15 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts @@ -1,3 +1,5 @@ +import crypto from 'crypto'; + import { ESCROW_BULK_PAYOUT_MAX_ITEMS, ChainId, @@ -7,20 +9,15 @@ import { OperatorUtils, } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; - -import crypto from 'crypto'; import { ethers } from 'ethers'; import stringify from 'json-stable-stringify'; import _ from 'lodash'; import { BACKOFF_INTERVAL_SECONDS } from '@/common/constants'; -import { isDuplicatedError } from '@/database'; import { JobManifest, JobRequestType } from '@/common/types'; import { ServerConfigService } from '@/config'; +import { isDuplicatedError } from '@/database'; import logger from '@/logger'; -import { calculateExponentialBackoffMs } from '@/utils/backoff'; -import * as manifestUtils from '@/utils/manifest'; - import { ReputationService } from '@/modules/reputation'; import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; @@ -28,18 +25,14 @@ import { OutgoingWebhookService, OutgoingWebhookEventType, } from '@/modules/webhook'; +import { calculateExponentialBackoffMs } from '@/utils/backoff'; +import * as manifestUtils from '@/utils/manifest'; import { DEFAULT_BULK_PAYOUT_TX_ID, EscrowCompletionStatus } from './constants'; -import { EscrowCompletionRepository } from './escrow-completion.repository'; import { EscrowCompletionEntity } from './escrow-completion.entity'; +import { EscrowCompletionRepository } from './escrow-completion.repository'; import { EscrowPayoutsBatchEntity } from './escrow-payouts-batch.entity'; import { EscrowPayoutsBatchRepository } from './escrow-payouts-batch.repository'; -import { - AudinoResultsProcessor, - CvatResultsProcessor, - EscrowResultsProcessor, - FortuneResultsProcessor, -} from './results-processing'; import { AudinoPayoutsCalculator, CvatPayoutsCalculator, @@ -47,6 +40,12 @@ import { EscrowPayoutsCalculator, CalculatedPayout, } from './payouts-calculation'; +import { + AudinoResultsProcessor, + CvatResultsProcessor, + EscrowResultsProcessor, + FortuneResultsProcessor, +} from './results-processing'; @Injectable() export class EscrowCompletionService { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts index cdfe9dcd05..1a06407f44 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index, ManyToOne } from 'typeorm'; -import { BaseEntity } from '@/database'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { BaseEntity } from '@/database'; import type { EscrowCompletionEntity } from './escrow-completion.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts index 9f41ba6993..e18fffbbcf 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-payouts-batch.repository.ts @@ -1,6 +1,8 @@ import { Injectable } from '@nestjs/common'; -import { BaseRepository } from '@/database'; import { DataSource } from 'typeorm'; + +import { BaseRepository } from '@/database'; + import { EscrowPayoutsBatchEntity } from './escrow-payouts-batch.entity'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts index df51cb52d7..86c627b947 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts @@ -4,7 +4,6 @@ import type { OverrideProperties } from 'type-fest'; import { AUDINO_VALIDATION_META_FILENAME } from '@/common/constants'; import { AudinoAnnotationMeta, AudinoManifest } from '@/common/types'; - import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts index faa49c243d..fe35e5eadf 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.spec.ts @@ -1,17 +1,16 @@ jest.mock('@human-protocol/sdk'); -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { EscrowClient } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; import _ from 'lodash'; import { CvatAnnotationMeta } from '@/common/types'; - import { StorageService } from '@/modules/storage'; -import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { Web3Service } from '@/modules/web3'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { CvatPayoutsCalculator } from './cvat-payouts-calculator'; import { generateCvatManifest } from '../fixtures'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts index 46d00d8129..5a3a34d617 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/cvat-payouts-calculator.ts @@ -5,7 +5,6 @@ import type { OverrideProperties } from 'type-fest'; import { CVAT_VALIDATION_META_FILENAME } from '@/common/constants'; import { CvatAnnotationMeta, CvatManifest } from '@/common/types'; - import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts index 8ed9420618..5fa8e7fe4f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.spec.ts @@ -1,5 +1,5 @@ -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; import _ from 'lodash'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts index f9909d02e3..fe89331717 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts @@ -3,7 +3,6 @@ import { ethers } from 'ethers'; import type { OverrideProperties } from 'type-fest'; import { FortuneFinalResult, FortuneManifest } from '@/common/types'; - import { StorageService } from '@/modules/storage'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts index 6972d83883..272d8c1dc9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/types.ts @@ -1,4 +1,5 @@ import { ChainId } from '@human-protocol/sdk'; + import { JobManifest } from '@/common/types'; export type CalculatedPayout = { diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts index 8ee621d741..8657462316 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/cvat-results-processor.spec.ts @@ -1,13 +1,13 @@ -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; import { PgpEncryptionService } from '@/modules/encryption'; import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; -import { BaseEscrowResultsProcessor } from './escrow-results-processor'; import { CvatResultsProcessor } from './cvat-results-processor'; +import { BaseEscrowResultsProcessor } from './escrow-results-processor'; const mockedStorageService = createMock(); const mockedPgpEncryptionService = createMock(); diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts index 576e35516c..fa03221b02 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.spec.ts @@ -1,19 +1,21 @@ jest.mock('@human-protocol/sdk'); -import { createMock } from '@golevelup/ts-jest'; +import * as crypto from 'crypto'; + import { faker } from '@faker-js/faker'; -import { EscrowClient, EscrowUtils } from '@human-protocol/sdk'; +import { createMock } from '@golevelup/ts-jest'; +import { EscrowClient, EscrowUtils, IEscrow } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; -import * as crypto from 'crypto'; +import { JobManifest } from '@/common/types'; import { PgpEncryptionService } from '@/modules/encryption'; import { StorageService } from '@/modules/storage'; -import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { Web3Service } from '@/modules/web3'; +import { generateTestnetChainId } from '@/modules/web3/fixtures'; import { BaseEscrowResultsProcessor } from './escrow-results-processor'; -class TestEscrowResultsProcessor extends BaseEscrowResultsProcessor { +class TestEscrowResultsProcessor extends BaseEscrowResultsProcessor { override constructIntermediateResultsUrl = jest.fn(); override assertResultsComplete = jest.fn(); @@ -79,7 +81,7 @@ describe('BaseEscrowResultsProcessor', () => { processor.storeResults( faker.number.int(), faker.finance.ethereumAddress(), - {}, + {} as unknown as JobManifest, ), ).rejects.toThrow(testError); }); @@ -114,7 +116,7 @@ describe('BaseEscrowResultsProcessor', () => { const jobLauncherAddress = faker.finance.ethereumAddress(); mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: jobLauncherAddress, - } as any); + } as unknown as IEscrow); const encryptedResult = faker.string.ulid(); mockedPgpEncryptionService.encrypt.mockResolvedValueOnce(encryptedResult); @@ -132,7 +134,7 @@ describe('BaseEscrowResultsProcessor', () => { mockedStorageService.uploadData.mockResolvedValueOnce(storedResultsUrl); /** ACT */ - const manifest = { resultToAssert: jobResult }; + const manifest = { resultToAssert: jobResult } as unknown as JobManifest; const storedResultMeta = await processor.storeResults( chainId, escrowAddress, diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts index 0a4080e765..4fd70e39bd 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/escrow-results-processor.ts @@ -1,10 +1,10 @@ +import crypto from 'crypto'; + import { ChainId, EscrowClient, EscrowUtils } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; -import crypto from 'crypto'; import { ContentType } from '@/common/enums'; import { JobManifest } from '@/common/types'; - import { PgpEncryptionService } from '@/modules/encryption'; import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts index 22c84e1e6b..ddfc763a10 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.spec.ts @@ -1,9 +1,8 @@ -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; import { FortuneFinalResult } from '@/common/types'; - import { PgpEncryptionService } from '@/modules/encryption'; import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts index 24f0403f70..c11bbe6cc9 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/results-processing/fortune-results-processor.ts @@ -17,7 +17,7 @@ export class FortuneResultsProcessor extends BaseEscrowResultsProcessor = { apiPrivateKey: faker.string.alphanumeric(), diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts index 4c99c196d3..433ac5db80 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc-webhook-auth.guard.ts @@ -1,3 +1,5 @@ +import { createHmac } from 'crypto'; + import { Injectable, CanActivate, @@ -5,7 +7,6 @@ import { HttpStatus, HttpException, } from '@nestjs/common'; -import { createHmac } from 'crypto'; import { Request } from 'express'; import { KycConfigService } from '@/config'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts index 9122a98522..4d9bdb8dbd 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.controller.ts @@ -19,6 +19,8 @@ import { import { Public } from '@/common/decorators'; import type { RequestWithUser } from '@/common/types'; + +import { KycWebhookAuthGuard } from './kyc-webhook-auth.guard'; import { StartSessionResponseDto, KycSignedAddressDto, @@ -26,7 +28,6 @@ import { } from './kyc.dto'; import { KycErrorFilter } from './kyc.error-filter'; import { KycService } from './kyc.service'; -import { KycWebhookAuthGuard } from './kyc-webhook-auth.guard'; @ApiTags('KYC') @Controller('/kyc') diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts index d06992ddf9..387cb34670 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts @@ -2,10 +2,10 @@ import { Column, Entity, JoinColumn, OneToOne } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; -import { KycStatus } from './constants'; - import type { UserEntity } from '@/modules/user'; +import { KycStatus } from './constants'; + @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'kycs' }) export class KycEntity extends BaseEntity { @Column({ type: 'varchar', unique: true, primary: true }) diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts index e9aed9acf9..033bb9581c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.error-filter.ts @@ -7,6 +7,7 @@ import { import { Request, Response } from 'express'; import logger from '@/logger'; + import { KycError } from './kyc.error'; @Catch(KycError) diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts index 5ea52c4e97..2b684ffe4e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.module.ts @@ -3,9 +3,10 @@ import { Module } from '@nestjs/common'; import { UserModule } from '@/modules/user'; import { Web3Module } from '@/modules/web3'; + import { KycController } from './kyc.controller'; -import { KycService } from './kyc.service'; import { KycRepository } from './kyc.repository'; +import { KycService } from './kyc.service'; @Module({ imports: [UserModule, HttpModule, Web3Module], diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts index a3bcaa6db7..3f7fcb9baf 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.repository.ts @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; import { BaseRepository } from '@/database'; + import { KycEntity } from './kyc.entity'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts index 45a8b5be9a..abe19b9496 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts @@ -4,24 +4,24 @@ import { HttpService } from '@nestjs/axios'; import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; +import { KycConfigService, Web3ConfigService } from '@/config'; +import { UserRepository } from '@/modules/user'; +import { generateWorkerUser } from '@/modules/user/fixtures'; +import { Web3Service } from '@/modules/web3'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; import { generateEthWallet } from '~/test/fixtures/web3'; import { createHttpServiceMock, createHttpServiceResponse, } from '~/test/mock-creators/nest'; -import { KycConfigService, Web3ConfigService } from '@/config'; -import { KycStatus } from './constants'; -import { UserRepository } from '@/modules/user'; -import { generateWorkerUser } from '@/modules/user/fixtures'; -import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; -import { Web3Service } from '@/modules/web3'; +import { KycStatus } from './constants'; +import { generateKycEntity, mockKycConfigService } from './fixtures'; import { UpdateKycStatusDto } from './kyc.dto'; import { KycEntity } from './kyc.entity'; import { KycError, KycErrorMessage } from './kyc.error'; import { KycRepository } from './kyc.repository'; import { KycService } from './kyc.service'; -import { generateKycEntity, mockKycConfigService } from './fixtures'; const mockHttpService = createHttpServiceMock(); @@ -220,7 +220,7 @@ describe('Kyc Service', () => { mockKycRepository.findOneBySessionId.mockResolvedValueOnce(mockKycEntity); mockKycUpdate.verification.document.country = null; - expect(kycService.updateKycStatus(mockKycUpdate)).rejects.toThrow( + await expect(kycService.updateKycStatus(mockKycUpdate)).rejects.toThrow( new KycError( KycErrorMessage.COUNTRY_NOT_SET, mockKycEntity.userId as number, diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts index fc09fbc2c2..c43867b988 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts @@ -5,9 +5,9 @@ import { catchError, firstValueFrom } from 'rxjs'; import { KycConfigService, Web3ConfigService } from '@/config'; import logger from '@/logger'; -import * as httpUtils from '@/utils/http'; import { UserNotFoundError, UserRepository } from '@/modules/user'; import { Web3Service } from '@/modules/web3'; +import * as httpUtils from '@/utils/http'; import { KycStatus } from './constants'; import { KycSignedAddressDto, UpdateKycStatusDto } from './kyc.dto'; diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts index 14d0c04ecf..81f784d175 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.error-filter.ts @@ -7,6 +7,7 @@ import { import { Request, Response } from 'express'; import logger from '@/logger'; + import { NDAError } from './nda.error'; @Catch(NDAError) diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts index 9c2ef2df89..afbf85a399 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.module.ts @@ -1,6 +1,7 @@ import { Module } from '@nestjs/common'; import { UserModule } from '@/modules/user'; + import { NDAController } from './nda.controller'; import { NDAService } from './nda.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts index 30d11af346..1624f86285 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.spec.ts @@ -1,15 +1,15 @@ -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { NDAConfigService } from '@/config'; -import { generateWorkerUser } from '@/modules/user/fixtures'; import { UserRepository } from '@/modules/user'; +import { generateWorkerUser } from '@/modules/user/fixtures'; +import { mockNdaConfigService } from './fixtures'; import { NDASignatureDto } from './nda.dto'; import { NDAError, NDAErrorMessage } from './nda.error'; import { NDAService } from './nda.service'; -import { mockNdaConfigService } from './fixtures'; const mockUserRepository = createMock(); diff --git a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts index ff2e016725..2b0ba22d0e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/nda/nda.service.ts @@ -1,7 +1,8 @@ import { Injectable } from '@nestjs/common'; -import { UserNotFoundError, UserRepository } from '@/modules/user'; import { NDAConfigService } from '@/config'; +import { UserNotFoundError, UserRepository } from '@/modules/user'; + import { NDASignatureDto } from './nda.dto'; import { NDAError, NDAErrorMessage } from './nda.error'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts index a5c8c8a83c..e88f3123ff 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts @@ -20,6 +20,7 @@ import { import { Public, Roles } from '@/common/decorators'; import { RolesAuthGuard } from '@/common/guards'; import { UserRole } from '@/modules/user'; + import { AssignQualificationDto, CreateQualificationDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts index ee33684eda..47665fa423 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.entity.ts @@ -2,6 +2,7 @@ import { Column, Entity, Index, OneToMany } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; + import type { UserQualificationEntity } from './user-qualification.entity'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'qualifications' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts index 059ebb74eb..bdf169ea76 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.error-filter.ts @@ -7,6 +7,7 @@ import { import { Request, Response } from 'express'; import logger from '@/logger'; + import { QualificationError, QualificationErrorMessage, diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts index bfdd62e365..d0bc98dac4 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.module.ts @@ -1,6 +1,7 @@ import { Module } from '@nestjs/common'; import { UserModule } from '@/modules/user'; + import { QualificationController } from './qualification.controller'; import { QualificationRepository } from './qualification.repository'; import { QualificationService } from './qualification.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts index b6087393d8..d0fd195413 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.repository.ts @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, IsNull, MoreThan } from 'typeorm'; import { BaseRepository } from '@/database'; + import { QualificationEntity } from './qualification.entity'; type FindOptions = { diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts index c5fe1ebdeb..3c079a08c3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts @@ -3,11 +3,11 @@ import { createMock } from '@golevelup/ts-jest'; import { ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; -import { generateFutureDate } from '~/test/fixtures/date'; -import { generateEthWallet } from '~/test/fixtures/web3'; import { ServerConfigService } from '@/config'; import { UserStatus, UserRepository } from '@/modules/user'; import { generateWorkerUser } from '@/modules/user/fixtures'; +import { generateFutureDate } from '~/test/fixtures/date'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { QualificationEntity } from './qualification.entity'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts index 61ee84194c..760b33110a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.entity.ts @@ -2,9 +2,10 @@ import { Column, Entity, ManyToOne, Index } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; -import type { QualificationEntity } from './qualification.entity'; import type { UserEntity } from '@/modules/user'; +import type { QualificationEntity } from './qualification.entity'; + @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'user_qualifications' }) @Index(['user', 'qualification'], { unique: true }) export class UserQualificationEntity extends BaseEntity { diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts index 5001111bee..c004e8ac8f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/user-qualification.repository.ts @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; import { BaseRepository } from '@/database'; + import { UserQualificationEntity } from './user-qualification.entity'; @Injectable() diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts index ba8750d47c..10527bf106 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.module.ts @@ -3,9 +3,9 @@ import { Module } from '@nestjs/common'; import { Web3Module } from '@/modules/web3'; -import { ReputationService } from './reputation.service'; -import { ReputationRepository } from './reputation.repository'; import { ReputationController } from './reputation.controller'; +import { ReputationRepository } from './reputation.repository'; +import { ReputationService } from './reputation.service'; @Module({ imports: [HttpModule, Web3Module], diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts index 96d59140ed..cbaa386606 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.spec.ts @@ -1,26 +1,25 @@ jest.mock('@human-protocol/sdk'); -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { EscrowClient } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; import { ReputationConfigService, Web3ConfigService } from '@/config'; - +import { Web3Service } from '@/modules/web3'; import { generateTestnetChainId, mockWeb3ConfigService, } from '@/modules/web3/fixtures'; -import { Web3Service } from '@/modules/web3'; +import { ReputationEntityType } from './constants'; import { generateRandomScorePoints, generateReputationEntity, generateReputationEntityType, } from './fixtures'; -import { ReputationService } from './reputation.service'; import { ReputationRepository } from './reputation.repository'; -import { ReputationEntityType } from './constants'; +import { ReputationService } from './reputation.service'; const mockReputationRepository = createMock(); diff --git a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts index c7e8c46166..3ec19aa471 100644 --- a/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/reputation/reputation.service.ts @@ -1,10 +1,9 @@ -import { Injectable } from '@nestjs/common'; import { ChainId, EscrowClient } from '@human-protocol/sdk'; +import { Injectable } from '@nestjs/common'; import { SortDirection } from '@/common/enums'; -import { isDuplicatedError } from '@/database'; import { ReputationConfigService, Web3ConfigService } from '@/config'; - +import { isDuplicatedError } from '@/database'; import { Web3Service } from '@/modules/web3'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts index c3eeee684b..9c8864a012 100644 --- a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.spec.ts @@ -1,15 +1,14 @@ jest.mock('minio'); -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; import { Client as MinioClient } from 'minio'; import { ContentType } from '@/common/enums'; import { S3ConfigService } from '@/config'; -import * as httpUtils from '@/utils/http'; - import { PgpEncryptionService } from '@/modules/encryption'; +import * as httpUtils from '@/utils/http'; import { MinioErrorCodes } from './minio.constants'; import { StorageService } from './storage.service'; diff --git a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts index 6264f259b3..105b797ee2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/storage/storage.service.ts @@ -4,9 +4,8 @@ import * as Minio from 'minio'; import { ContentType } from '@/common/enums'; import { S3ConfigService } from '@/config'; import logger from '@/logger'; -import * as httpUtils from '@/utils/http'; - import { PgpEncryptionService } from '@/modules/encryption'; +import * as httpUtils from '@/utils/http'; import { MinioErrorCodes } from './minio.constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts index 349f927750..7cd97eb5cb 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts @@ -1,10 +1,9 @@ import { faker } from '@faker-js/faker'; import { SetNonNullable } from 'type-fest'; -import { generateEthWallet } from '~/test/fixtures/web3'; - import * as securityUtils from '@/utils/security'; import * as web3Utils from '@/utils/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { OperatorUserEntity, Web2UserEntity } from '../types'; import { Role, UserStatus } from '../user.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts index 40e15f3026..f32a2837ad 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.controller.ts @@ -1,10 +1,3 @@ -import { - ApiBearerAuth, - ApiOperation, - ApiResponse, - ApiTags, - ApiBody, -} from '@nestjs/swagger'; import { Body, Controller, @@ -16,6 +9,13 @@ import { Get, UseFilters, } from '@nestjs/common'; +import { + ApiBearerAuth, + ApiOperation, + ApiResponse, + ApiTags, + ApiBody, +} from '@nestjs/swagger'; import { Public } from '@/common/decorators'; import { SignatureType } from '@/common/enums'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts index 752df76d4a..097a315ac2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts @@ -3,7 +3,6 @@ import { Column, Entity, OneToMany, OneToOne } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; - import type { KycEntity } from '@/modules/kyc'; import type { UserQualificationEntity } from '@/modules/qualification'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts index eb177d8be6..1621b95c93 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.module.ts @@ -1,7 +1,6 @@ import { Module } from '@nestjs/common'; import { HCaptchaModule } from '@/integrations/hcaptcha'; - import { Web3Module } from '@/modules/web3'; import { SiteKeyRepository } from './site-key.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts index 6074bd3234..6dbe6385a1 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts @@ -5,25 +5,23 @@ import { createMock } from '@golevelup/ts-jest'; import { KVStoreClient, KVStoreUtils } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; -import { generateEthWallet } from '~/test/fixtures/web3'; - import { SignatureType } from '@/common/enums'; import { Web3ConfigService } from '@/config'; import { HCaptchaService } from '@/integrations/hcaptcha/hcaptcha.service'; -import * as web3Utils from '@/utils/web3'; - import { KycStatus } from '@/modules/kyc'; import { generateKycEntity } from '@/modules/kyc/fixtures'; -import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; import { Web3Service } from '@/modules/web3'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; +import * as web3Utils from '@/utils/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; import { generateSiteKeyEntity, generateOperator, generateWorkerUser, } from './fixtures'; -import { SiteKeyRepository } from './site-key.repository'; import { SiteKeyType } from './site-key.entity'; +import { SiteKeyRepository } from './site-key.repository'; import { Role } from './user.entity'; import { DuplicatedWalletAddressError, diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts index 4b2513baa6..6a508276a1 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts @@ -4,10 +4,9 @@ import { Injectable } from '@nestjs/common'; import { SignatureType } from '@/common/enums'; import { Web3ConfigService } from '@/config'; import { HCaptchaService } from '@/integrations/hcaptcha/hcaptcha.service'; -import * as web3Utils from '@/utils/web3'; - import { KycStatus } from '@/modules/kyc'; import { Web3Service } from '@/modules/web3'; +import * as web3Utils from '@/utils/web3'; import { SiteKeyEntity, SiteKeyType } from './site-key.entity'; import { SiteKeyRepository } from './site-key.repository'; @@ -213,7 +212,9 @@ export class UserService { signer.address, operatorUser.evmAddress, ); - } catch {} + } catch { + // noop + } if (status === OperatorStatus.ACTIVE) { throw new UserError( diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts index 33ddb43b84..fde77f55ed 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/fixtures/index.ts @@ -1,4 +1,5 @@ import { faker } from '@faker-js/faker'; + import { Web3ConfigService, Web3Network } from '@/config'; import { generateEthWallet } from '~/test/fixtures/web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/types.ts b/packages/apps/reputation-oracle/server/src/modules/web3/types.ts index 6fc7a5e452..cbb557ab49 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/types.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/types.ts @@ -1,5 +1,4 @@ import { ChainId } from '@human-protocol/sdk'; - import type { Provider, Wallet } from 'ethers'; export type Chain = { diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts index 0a2cc6bae0..adef07f9e6 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.spec.ts @@ -1,14 +1,13 @@ -import { createMock } from '@golevelup/ts-jest'; import { faker } from '@faker-js/faker'; +import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; import { FeeData, JsonRpcProvider, Provider } from 'ethers'; import { Web3ConfigService } from '@/config'; -import { Web3Service } from './web3.service'; -import type { WalletWithProvider } from './types'; - import { generateTestnetChainId, mockWeb3ConfigService } from './fixtures'; +import type { WalletWithProvider } from './types'; +import { Web3Service } from './web3.service'; describe('Web3Service', () => { let web3Service: Web3Service; diff --git a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts index 189673cf2d..e9a31b0349 100644 --- a/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/web3/web3.service.ts @@ -1,7 +1,9 @@ import { ChainId } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { Wallet, ethers } from 'ethers'; + import { Web3ConfigService, Web3Network } from '@/config'; + import type { Chain, WalletWithProvider } from './types'; export const supportedChainIdsByNetwork = { diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts index 9ead719155..9a5f529a2a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/fixtures/index.ts @@ -1,8 +1,10 @@ -import { faker } from '@faker-js/faker'; import * as crypto from 'crypto'; + +import { faker } from '@faker-js/faker'; import stringify from 'json-stable-stringify'; import { generateTestnetChainId } from '@/modules/web3/fixtures'; + import { IncomingWebhookStatus, OutgoingWebhookEventType, diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts index bd0ad85656..b8df9bcd55 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.entity.ts @@ -2,6 +2,7 @@ import { Column, Entity, Index } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; + import { IncomingWebhookStatus } from './types'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'webhook_incoming' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts index 687a881099..e35a729f2c 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.module.ts @@ -3,9 +3,9 @@ import { Module } from '@nestjs/common'; import { EscrowCompletionModule } from '@/modules/escrow-completion'; -import { WebhookController } from './webhook.controller'; import { IncomingWebhookRepository } from './webhook-incoming.repository'; import { IncomingWebhookService } from './webhook-incoming.service'; +import { WebhookController } from './webhook.controller'; @Module({ imports: [HttpModule, EscrowCompletionModule], diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts index 6fe518294f..e306f47fe6 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.repository.ts @@ -3,6 +3,7 @@ import { DataSource, LessThanOrEqual } from 'typeorm'; import { ServerConfigService } from '@/config'; import { BaseRepository } from '@/database'; + import { IncomingWebhookStatus } from './types'; import { IncomingWebhookEntity } from './webhook-incoming.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts index 208894074e..1dcc89baef 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.spec.ts @@ -2,8 +2,8 @@ import { faker } from '@faker-js/faker'; import { createMock } from '@golevelup/ts-jest'; import { Test } from '@nestjs/testing'; -import { DatabaseError, DatabaseErrorMessages } from '@/database'; import { ServerConfigService } from '@/config'; +import { DatabaseError, DatabaseErrorMessages } from '@/database'; import { EscrowCompletionService } from '@/modules/escrow-completion'; import { generateTestnetChainId } from '@/modules/web3/fixtures'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts index a221546dae..1473f1c6b8 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-incoming.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { BACKOFF_INTERVAL_SECONDS } from '@/common/constants'; -import { isDuplicatedError } from '@/database'; import { ServerConfigService } from '@/config'; +import { isDuplicatedError } from '@/database'; +import logger from '@/logger'; import { EscrowCompletionService } from '@/modules/escrow-completion'; import { calculateExponentialBackoffMs } from '@/utils/backoff'; -import logger from '@/logger'; import { IncomingWebhookData, IncomingWebhookStatus } from './types'; import { IncomingWebhookEntity } from './webhook-incoming.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts index a929d5c2e3..5316d9c9d6 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.entity.ts @@ -2,6 +2,7 @@ import { Column, Entity, Index } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; import { BaseEntity } from '@/database'; + import { OutgoingWebhookStatus } from './types'; @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'webhook_outgoing' }) diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts index 4b908418db..771a15cf92 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.repository.ts @@ -3,6 +3,7 @@ import { DataSource, LessThanOrEqual } from 'typeorm'; import { ServerConfigService } from '@/config'; import { BaseRepository } from '@/database'; + import { OutgoingWebhookStatus } from './types'; import { OutgoingWebhookEntity } from './webhook-outgoing.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts index 7b92ee4aef..0346bdfa20 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.spec.ts @@ -1,19 +1,21 @@ +import * as crypto from 'crypto'; + import { faker } from '@faker-js/faker'; import { createMock } from '@golevelup/ts-jest'; import { HttpService } from '@nestjs/axios'; import { Test } from '@nestjs/testing'; -import * as crypto from 'crypto'; import stringify from 'json-stable-stringify'; -import { - createHttpServiceMock, - createHttpServiceResponse, -} from '~/test/mock-creators/nest'; import { HEADER_SIGNATURE_KEY } from '@/common/constants'; import { ServerConfigService, Web3ConfigService } from '@/config'; +import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; import { signMessage } from '@/utils/web3'; -import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; +import { + createHttpServiceMock, + createHttpServiceResponse, +} from '~/test/mock-creators/nest'; + import { generateOutgoingWebhookPayload, generateOutgoingWebhook, diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts index e8a6704871..92cfa49379 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook-outgoing.service.ts @@ -1,6 +1,8 @@ +import * as crypto from 'crypto'; + import { HttpService } from '@nestjs/axios'; import { Injectable } from '@nestjs/common'; -import * as crypto from 'crypto'; +import { AxiosError } from 'axios'; import stringify from 'json-stable-stringify'; import { firstValueFrom } from 'rxjs'; @@ -9,11 +11,11 @@ import { HEADER_SIGNATURE_KEY, } from '@/common/constants'; import { ServerConfigService, Web3ConfigService } from '@/config'; +import logger from '@/logger'; import { calculateExponentialBackoffMs } from '@/utils/backoff'; import { transformKeysFromCamelToSnake } from '@/utils/case-converters'; -import { formatAxiosError } from '@/utils/http'; +import * as httpUtils from '@/utils/http'; import { signMessage } from '@/utils/web3'; -import logger from '@/logger'; import { OutgoingWebhookStatus } from './types'; import { OutgoingWebhookEntity } from './webhook-outgoing.entity'; @@ -85,12 +87,16 @@ export class OutgoingWebhookService { }), ); } catch (error) { - const formattedError = formatAxiosError(error); - this.logger.error('Webhook not sent', { + let formattedError = error; + if (error instanceof AxiosError) { + formattedError = httpUtils.formatAxiosError(error); + } + const message = 'Webhook not sent'; + this.logger.error(message, { error: formattedError, hash: outgoingWebhook.hash, }); - throw new Error(formattedError.message); + throw new Error(message); } } diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts index 3b876b9a0a..0dea83c281 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.controller.ts @@ -1,5 +1,4 @@ import { Body, Controller, HttpCode, Post, UseGuards } from '@nestjs/common'; - import { ApiBody, ApiHeader, diff --git a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts index 2a87f875da..4731a4e7cb 100644 --- a/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/webhook/webhook.dto.ts @@ -3,6 +3,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsEthereumAddress, IsObject, IsOptional } from 'class-validator'; import { IsChainId, IsLowercasedEnum } from '@/common/validators'; + import { IncomingWebhookEventType } from './types'; export class IncomingWebhookDto { diff --git a/packages/apps/reputation-oracle/server/src/utils/backoff.spec.ts b/packages/apps/reputation-oracle/server/src/utils/backoff.spec.ts index e70f79a219..303f2b2d8d 100644 --- a/packages/apps/reputation-oracle/server/src/utils/backoff.spec.ts +++ b/packages/apps/reputation-oracle/server/src/utils/backoff.spec.ts @@ -1,4 +1,5 @@ import { faker } from '@faker-js/faker'; + import { calculateExponentialBackoffMs } from './backoff'; describe('Backoff utilities', () => { diff --git a/packages/apps/reputation-oracle/server/src/utils/case-converters.spec.ts b/packages/apps/reputation-oracle/server/src/utils/case-converters.spec.ts index d837423205..8943db390b 100644 --- a/packages/apps/reputation-oracle/server/src/utils/case-converters.spec.ts +++ b/packages/apps/reputation-oracle/server/src/utils/case-converters.spec.ts @@ -1,4 +1,5 @@ import { faker } from '@faker-js/faker'; + import * as CaseConverter from './case-converters'; describe('Case converting utilities', () => { diff --git a/packages/apps/reputation-oracle/server/src/utils/http.spec.ts b/packages/apps/reputation-oracle/server/src/utils/http.spec.ts index d34972dcca..0819a25e2f 100644 --- a/packages/apps/reputation-oracle/server/src/utils/http.spec.ts +++ b/packages/apps/reputation-oracle/server/src/utils/http.spec.ts @@ -1,9 +1,10 @@ +import { Readable } from 'stream'; + import { faker } from '@faker-js/faker'; -import axios from 'axios'; +import axios, { AxiosError } from 'axios'; import nock from 'nock'; import * as httpUtils from './http'; -import { Readable } from 'stream'; describe('HTTP utilities', () => { describe('formatAxiosError', () => { @@ -23,7 +24,9 @@ describe('HTTP utilities', () => { const EXPECTED_CAUSE = 'synthetic'; thrownError.cause = EXPECTED_CAUSE; - const formattedError = httpUtils.formatAxiosError(thrownError); + const formattedError = httpUtils.formatAxiosError( + thrownError as AxiosError, + ); const ERROR_NAME = 'CanceledError'; const EXPECTED_MESSAGE = 'canceled'; diff --git a/packages/apps/reputation-oracle/server/src/utils/http.ts b/packages/apps/reputation-oracle/server/src/utils/http.ts index 3789ec0849..1d3dd2eb3c 100644 --- a/packages/apps/reputation-oracle/server/src/utils/http.ts +++ b/packages/apps/reputation-oracle/server/src/utils/http.ts @@ -1,6 +1,7 @@ -import axios, { AxiosError } from 'axios'; import { Readable } from 'stream'; +import axios, { AxiosError } from 'axios'; + import { BaseError } from '@/common/errors/base'; export function formatAxiosError(error: AxiosError) { @@ -30,7 +31,7 @@ function isValidUrl(maybeUrl: string, protocols?: string[]): boolean { } return true; - } catch (_error) { + } catch { return false; } } diff --git a/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts b/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts index dda0be8c2f..f930a2a375 100644 --- a/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts +++ b/packages/apps/reputation-oracle/server/src/utils/web3.spec.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { generateEthWallet } from '@/test/fixtures/web3'; +import { generateEthWallet } from '~/test/fixtures/web3'; import * as web3Utils from './web3'; diff --git a/packages/apps/reputation-oracle/server/test/mock-creators/nest.ts b/packages/apps/reputation-oracle/server/test/mock-creators/nest.ts index 298fbd4b14..86d7ce9253 100644 --- a/packages/apps/reputation-oracle/server/test/mock-creators/nest.ts +++ b/packages/apps/reputation-oracle/server/test/mock-creators/nest.ts @@ -1,6 +1,6 @@ import { HttpService } from '@nestjs/axios'; -import { AxiosResponse } from 'axios'; import { CallHandler, ExecutionContext } from '@nestjs/common'; +import { AxiosResponse } from 'axios'; import { of, throwError } from 'rxjs'; class MockClassOfExecutionContext {} diff --git a/yarn.lock b/yarn.lock index 0068e60718..ccda1e4bb4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2760,6 +2760,13 @@ __metadata: languageName: node linkType: hard +"@eslint/config-helpers@npm:^0.3.1": + version: 0.3.1 + resolution: "@eslint/config-helpers@npm:0.3.1" + checksum: 10c0/f6c5b3a0b76a0d7d84cc93e310c259e6c3e0792ddd0a62c5fc0027796ffae44183432cb74b2c2b1162801ee1b1b34a6beb5d90a151632b4df7349f994146a856 + languageName: node + linkType: hard + "@eslint/core@npm:^0.14.0": version: 0.14.0 resolution: "@eslint/core@npm:0.14.0" @@ -2769,6 +2776,15 @@ __metadata: languageName: node linkType: hard +"@eslint/core@npm:^0.15.2": + version: 0.15.2 + resolution: "@eslint/core@npm:0.15.2" + dependencies: + "@types/json-schema": "npm:^7.0.15" + checksum: 10c0/c17a6dc4f5a6006ecb60165cc38bcd21fefb4a10c7a2578a0cfe5813bbd442531a87ed741da5adab5eb678e8e693fda2e2b14555b035355537e32bcec367ea17 + languageName: node + linkType: hard + "@eslint/eslintrc@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/eslintrc@npm:2.1.4" @@ -2824,6 +2840,13 @@ __metadata: languageName: node linkType: hard +"@eslint/js@npm:9.33.0, @eslint/js@npm:^9.33.0": + version: 9.33.0 + resolution: "@eslint/js@npm:9.33.0" + checksum: 10c0/4c42c9abde76a183b8e47205fd6c3116b058f82f07b6ad4de40de56cdb30a36e9ecd40efbea1b63a84d08c206aadbb0aa39a890197e1ad6455a8e542df98f186 + languageName: node + linkType: hard + "@eslint/object-schema@npm:^2.1.6": version: 2.1.6 resolution: "@eslint/object-schema@npm:2.1.6" @@ -2841,6 +2864,16 @@ __metadata: languageName: node linkType: hard +"@eslint/plugin-kit@npm:^0.3.5": + version: 0.3.5 + resolution: "@eslint/plugin-kit@npm:0.3.5" + dependencies: + "@eslint/core": "npm:^0.15.2" + levn: "npm:^0.4.1" + checksum: 10c0/c178c1b58c574200c0fd125af3e4bc775daba7ce434ba6d1eeaf9bcb64b2e9fea75efabffb3ed3ab28858e55a016a5efa95f509994ee4341b341199ca630b89e + languageName: node + linkType: hard + "@ethereumjs/common@npm:^3.2.0": version: 3.2.0 resolution: "@ethereumjs/common@npm:3.2.0" @@ -4507,6 +4540,7 @@ __metadata: version: 0.0.0-use.local resolution: "@human-protocol/reputation-oracle@workspace:packages/apps/reputation-oracle/server" dependencies: + "@eslint/js": "npm:^9.33.0" "@faker-js/faker": "npm:^9.4.0" "@golevelup/ts-jest": "npm:^0.6.1" "@human-protocol/core": "workspace:*" @@ -4538,18 +4572,19 @@ __metadata: "@types/passport-jwt": "npm:^4.0.1" "@types/uuid": "npm:^10.0.0" "@types/zxcvbn": "npm:4.4.5" - "@typescript-eslint/eslint-plugin": "npm:^5.0.0" - "@typescript-eslint/parser": "npm:^5.0.0" axios: "npm:^1.8.1" bcrypt: "npm:^5.1.1" body-parser: "npm:^1.20.3" class-transformer: "npm:^0.5.1" class-validator: "npm:^0.14.1" dotenv: "npm:^17.0.0" - eslint: "npm:^8.55.0" - eslint-config-prettier: "npm:^9.1.0" - eslint-plugin-prettier: "npm:^5.2.1" + eslint: "npm:^9.33.0" + eslint-config-prettier: "npm:^10.1.8" + eslint-import-resolver-typescript: "npm:^4.4.4" + eslint-plugin-import: "npm:^2.32.0" + eslint-plugin-prettier: "npm:^5.5.4" ethers: "npm:~6.13.5" + globals: "npm:^16.3.0" helmet: "npm:^7.1.0" jest: "npm:29.7.0" joi: "npm:^17.13.3" @@ -4563,14 +4598,14 @@ __metadata: prettier: "npm:^3.4.2" reflect-metadata: "npm:^0.2.2" rxjs: "npm:^7.2.0" - source-map-support: "npm:^0.5.20" ts-jest: "npm:29.2.5" ts-node: "npm:^10.9.2" tsconfig-paths: "npm:^4.2.0" type-fest: "npm:^4.37.0" typeorm: "npm:^0.3.25" typeorm-naming-strategies: "npm:^4.1.0" - typescript: "npm:^5.6.3" + typescript: "npm:^5.9.2" + typescript-eslint: "npm:^8.39.1" uuid: "npm:^11.1.0" zxcvbn: "npm:^4.4.2" languageName: unknown @@ -10876,6 +10911,27 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/eslint-plugin@npm:8.39.1" + dependencies: + "@eslint-community/regexpp": "npm:^4.10.0" + "@typescript-eslint/scope-manager": "npm:8.39.1" + "@typescript-eslint/type-utils": "npm:8.39.1" + "@typescript-eslint/utils": "npm:8.39.1" + "@typescript-eslint/visitor-keys": "npm:8.39.1" + graphemer: "npm:^1.4.0" + ignore: "npm:^7.0.0" + natural-compare: "npm:^1.4.0" + ts-api-utils: "npm:^2.1.0" + peerDependencies: + "@typescript-eslint/parser": ^8.39.1 + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/7a55de558ed6ea6f09ee0b0d994b4a70e1df9f72e4afc7b3073de1b41504a36d905779304d59c34db700af60da3bb438c62480d30462a13b8b72d0b50318aeee + languageName: node + linkType: hard + "@typescript-eslint/eslint-plugin@npm:^5.0.0, @typescript-eslint/eslint-plugin@npm:^5.5.0": version: 5.62.0 resolution: "@typescript-eslint/eslint-plugin@npm:5.62.0" @@ -10991,6 +11047,22 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/parser@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/parser@npm:8.39.1" + dependencies: + "@typescript-eslint/scope-manager": "npm:8.39.1" + "@typescript-eslint/types": "npm:8.39.1" + "@typescript-eslint/typescript-estree": "npm:8.39.1" + "@typescript-eslint/visitor-keys": "npm:8.39.1" + debug: "npm:^4.3.4" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/da30372c4e8dee48a0c421996bf0bf73a62a57039ee6b817eda64de2d70fdb88dd20b50615c81be7e68fd29cdd7852829b859bb8539b4a4c78030f93acaf5664 + languageName: node + linkType: hard + "@typescript-eslint/parser@npm:^5.0.0, @typescript-eslint/parser@npm:^5.5.0": version: 5.62.0 resolution: "@typescript-eslint/parser@npm:5.62.0" @@ -11068,6 +11140,19 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/project-service@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/project-service@npm:8.39.1" + dependencies: + "@typescript-eslint/tsconfig-utils": "npm:^8.39.1" + "@typescript-eslint/types": "npm:^8.39.1" + debug: "npm:^4.3.4" + peerDependencies: + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/40207af4f4e2a260ea276766d502c4736f6dc5488e84bbab6444e2786289ece2dbca2686323c48d4e9c265e409a309bf3d97d4aa03767dff8cc7642b436bda35 + languageName: node + linkType: hard + "@typescript-eslint/scope-manager@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/scope-manager@npm:5.62.0" @@ -11128,6 +11213,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/scope-manager@npm:8.39.1" + dependencies: + "@typescript-eslint/types": "npm:8.39.1" + "@typescript-eslint/visitor-keys": "npm:8.39.1" + checksum: 10c0/9466db557c1a0eaaf24b0ece5810413d11390d046bf6e47c4074879e8dba0348b835a21106c842ab20ff85f2384312cf9e20bfe7684e31640696e29957003511 + languageName: node + linkType: hard + "@typescript-eslint/tsconfig-utils@npm:8.33.0, @typescript-eslint/tsconfig-utils@npm:^8.33.0": version: 8.33.0 resolution: "@typescript-eslint/tsconfig-utils@npm:8.33.0" @@ -11146,6 +11241,15 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/tsconfig-utils@npm:8.39.1, @typescript-eslint/tsconfig-utils@npm:^8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/tsconfig-utils@npm:8.39.1" + peerDependencies: + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/664dff0b4ae908cb98c78f9ca73c36cf57c3a2206965d9d0659649ffc02347eb30e1452499671a425592f14a2a5c5eb82ae389b34f3c415a12119506b4ebb61c + languageName: node + linkType: hard + "@typescript-eslint/type-utils@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/type-utils@npm:5.62.0" @@ -11227,6 +11331,22 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/type-utils@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/type-utils@npm:8.39.1" + dependencies: + "@typescript-eslint/types": "npm:8.39.1" + "@typescript-eslint/typescript-estree": "npm:8.39.1" + "@typescript-eslint/utils": "npm:8.39.1" + debug: "npm:^4.3.4" + ts-api-utils: "npm:^2.1.0" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/430dfefe040eae5f0c8dfbce37b5ce071095a28f335e74793923d113682e26313586e90f7bbe2c2f9bffb0da52ffdf5055ea36b96d9f218cef35aa14853122d5 + languageName: node + linkType: hard + "@typescript-eslint/types@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/types@npm:5.62.0" @@ -11269,6 +11389,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:8.39.1, @typescript-eslint/types@npm:^8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/types@npm:8.39.1" + checksum: 10c0/0e188d2d52509a24c500a87adf561387ffcac56b62cb9fd0ca1f929bb3d4eedb6b8f9d516c1890855d39930c9dd8d502d5b4600b8c9cc832d3ebb595d81c7533 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/typescript-estree@npm:5.62.0" @@ -11383,6 +11510,26 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/typescript-estree@npm:8.39.1" + dependencies: + "@typescript-eslint/project-service": "npm:8.39.1" + "@typescript-eslint/tsconfig-utils": "npm:8.39.1" + "@typescript-eslint/types": "npm:8.39.1" + "@typescript-eslint/visitor-keys": "npm:8.39.1" + debug: "npm:^4.3.4" + fast-glob: "npm:^3.3.2" + is-glob: "npm:^4.0.3" + minimatch: "npm:^9.0.4" + semver: "npm:^7.6.0" + ts-api-utils: "npm:^2.1.0" + peerDependencies: + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/1de1a37fed354600a08bc971492c2f14238f0a4bf07a43bedb416c17b7312d18bec92c68c8f2790bb0a1bffcd757f7962914be9f6213068f18f6c4fdde259af4 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:5.62.0, @typescript-eslint/utils@npm:^5.10.0, @typescript-eslint/utils@npm:^5.58.0, @typescript-eslint/utils@npm:^5.62.0": version: 5.62.0 resolution: "@typescript-eslint/utils@npm:5.62.0" @@ -11462,6 +11609,21 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/utils@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/utils@npm:8.39.1" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.7.0" + "@typescript-eslint/scope-manager": "npm:8.39.1" + "@typescript-eslint/types": "npm:8.39.1" + "@typescript-eslint/typescript-estree": "npm:8.39.1" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/ebc01d736af43728df9a0915058d0c771dec9cc58846ffdcbb986c78e7dabf547ea7daecd75db58b2af88a3c2a43de8a7e5f81feefacfa31be173fc384d25d77 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:^8.18.1": version: 8.32.0 resolution: "@typescript-eslint/utils@npm:8.32.0" @@ -11537,6 +11699,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:8.39.1": + version: 8.39.1 + resolution: "@typescript-eslint/visitor-keys@npm:8.39.1" + dependencies: + "@typescript-eslint/types": "npm:8.39.1" + eslint-visitor-keys: "npm:^4.2.1" + checksum: 10c0/4d81f6826a211bc2752e25cd16d1f415f28ebc92b35142402ec23f3765f2d00963b75ac06266ad9c674ca5b057d07d8c114116e5bf14f5465dde1d1aa60bc72f + languageName: node + linkType: hard + "@ungap/structured-clone@npm:^1.2.0": version: 1.3.0 resolution: "@ungap/structured-clone@npm:1.3.0" @@ -17238,6 +17410,17 @@ __metadata: languageName: node linkType: hard +"eslint-config-prettier@npm:^10.1.8": + version: 10.1.8 + resolution: "eslint-config-prettier@npm:10.1.8" + peerDependencies: + eslint: ">=7.0.0" + bin: + eslint-config-prettier: bin/cli.js + checksum: 10c0/e1bcfadc9eccd526c240056b1e59c5cd26544fe59feb85f38f4f1f116caed96aea0b3b87868e68b3099e55caaac3f2e5b9f58110f85db893e83a332751192682 + languageName: node + linkType: hard + "eslint-config-prettier@npm:^9.1.0": version: 9.1.0 resolution: "eslint-config-prettier@npm:9.1.0" @@ -17599,6 +17782,26 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-prettier@npm:^5.5.4": + version: 5.5.4 + resolution: "eslint-plugin-prettier@npm:5.5.4" + dependencies: + prettier-linter-helpers: "npm:^1.0.0" + synckit: "npm:^0.11.7" + peerDependencies: + "@types/eslint": ">=8.0.0" + eslint: ">=8.0.0" + eslint-config-prettier: ">= 7.0.0 <10.0.0 || >=10.1.0" + prettier: ">=3.0.0" + peerDependenciesMeta: + "@types/eslint": + optional: true + eslint-config-prettier: + optional: true + checksum: 10c0/5cc780e0ab002f838ad8057409e86de4ff8281aa2704a50fa8511abff87028060c2e45741bc9cbcbd498712e8d189de8026e70aed9e20e50fe5ba534ee5a8442 + languageName: node + linkType: hard + "eslint-plugin-react-hooks@npm:^4.3.0, eslint-plugin-react-hooks@npm:^4.6.0": version: 4.6.2 resolution: "eslint-plugin-react-hooks@npm:4.6.2" @@ -17945,6 +18148,56 @@ __metadata: languageName: node linkType: hard +"eslint@npm:^9.33.0": + version: 9.33.0 + resolution: "eslint@npm:9.33.0" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.2.0" + "@eslint-community/regexpp": "npm:^4.12.1" + "@eslint/config-array": "npm:^0.21.0" + "@eslint/config-helpers": "npm:^0.3.1" + "@eslint/core": "npm:^0.15.2" + "@eslint/eslintrc": "npm:^3.3.1" + "@eslint/js": "npm:9.33.0" + "@eslint/plugin-kit": "npm:^0.3.5" + "@humanfs/node": "npm:^0.16.6" + "@humanwhocodes/module-importer": "npm:^1.0.1" + "@humanwhocodes/retry": "npm:^0.4.2" + "@types/estree": "npm:^1.0.6" + "@types/json-schema": "npm:^7.0.15" + ajv: "npm:^6.12.4" + chalk: "npm:^4.0.0" + cross-spawn: "npm:^7.0.6" + debug: "npm:^4.3.2" + escape-string-regexp: "npm:^4.0.0" + eslint-scope: "npm:^8.4.0" + eslint-visitor-keys: "npm:^4.2.1" + espree: "npm:^10.4.0" + esquery: "npm:^1.5.0" + esutils: "npm:^2.0.2" + fast-deep-equal: "npm:^3.1.3" + file-entry-cache: "npm:^8.0.0" + find-up: "npm:^5.0.0" + glob-parent: "npm:^6.0.2" + ignore: "npm:^5.2.0" + imurmurhash: "npm:^0.1.4" + is-glob: "npm:^4.0.0" + json-stable-stringify-without-jsonify: "npm:^1.0.1" + lodash.merge: "npm:^4.6.2" + minimatch: "npm:^3.1.2" + natural-compare: "npm:^1.4.0" + optionator: "npm:^0.9.3" + peerDependencies: + jiti: "*" + peerDependenciesMeta: + jiti: + optional: true + bin: + eslint: bin/eslint.js + checksum: 10c0/1e1f60d2b62d9d65553e9af916a8dccf00eeedd982103f35bf58c205803907cb1fda73ef595178d47384ea80d8624a182b63682a6b15d8387e9a5d86904a2a2d + languageName: node + linkType: hard + "espree@npm:^10.0.1, espree@npm:^10.3.0": version: 10.3.0 resolution: "espree@npm:10.3.0" @@ -29256,6 +29509,21 @@ __metadata: languageName: node linkType: hard +"typescript-eslint@npm:^8.39.1": + version: 8.39.1 + resolution: "typescript-eslint@npm:8.39.1" + dependencies: + "@typescript-eslint/eslint-plugin": "npm:8.39.1" + "@typescript-eslint/parser": "npm:8.39.1" + "@typescript-eslint/typescript-estree": "npm:8.39.1" + "@typescript-eslint/utils": "npm:8.39.1" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <6.0.0" + checksum: 10c0/4070729621c20f8a9bad3df13fb8ac175609a57d046c155df785d474c2926d3e506f0bd5e762be7e2aacd03839c9c9a2015ad087086cee5838c486b9bf46b27b + languageName: node + linkType: hard + "typescript@npm:5.7.2": version: 5.7.2 resolution: "typescript@npm:5.7.2" @@ -29276,6 +29544,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:^5.9.2": + version: 5.9.2 + resolution: "typescript@npm:5.9.2" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/cd635d50f02d6cf98ed42de2f76289701c1ec587a363369255f01ed15aaf22be0813226bff3c53e99d971f9b540e0b3cc7583dbe05faded49b1b0bed2f638a18 + languageName: node + linkType: hard + "typescript@patch:typescript@npm%3A5.7.2#optional!builtin": version: 5.7.2 resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin::version=5.7.2&hash=5786d5" @@ -29296,6 +29574,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@npm%3A^5.9.2#optional!builtin": + version: 5.9.2 + resolution: "typescript@patch:typescript@npm%3A5.9.2#optional!builtin::version=5.9.2&hash=5786d5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/34d2a8e23eb8e0d1875072064d5e1d9c102e0bdce56a10a25c0b917b8aa9001a9cf5c225df12497e99da107dc379360bc138163c66b55b95f5b105b50578067e + languageName: node + linkType: hard + "typical@npm:^4.0.0": version: 4.0.0 resolution: "typical@npm:4.0.0" From ba6348fa4af35f805703fd9186824d45ed5f2f4e Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Tue, 12 Aug 2025 14:42:40 +0300 Subject: [PATCH 6/6] fix: tests and circular deps --- .../reputation-oracle/server/jest.config.ts | 15 ++++---- .../server/src/common/decorators/index.ts | 2 +- .../server/src/common/enums/index.ts | 1 + .../kyc/constants.ts => common/enums/user.ts} | 12 +++++++ .../server/src/common/guards/roles.auth.ts | 2 +- .../server/src/database/database.module.ts | 35 +++++++++---------- .../src/modules/auth/auth.service.spec.ts | 10 ++---- .../server/src/modules/auth/auth.service.ts | 4 +-- .../src/modules/auth/dto/sign-up.dto.ts | 2 +- .../src/modules/auth/jwt-http-strategy.ts | 2 +- .../escrow-completion.module.ts | 4 ++- .../escrow-completion.service.ts | 9 ++--- .../server/src/modules/kyc/fixtures/index.ts | 2 +- .../server/src/modules/kyc/index.ts | 1 - .../server/src/modules/kyc/kyc.dto.ts | 2 +- .../server/src/modules/kyc/kyc.entity.ts | 3 +- .../src/modules/kyc/kyc.service.spec.ts | 2 +- .../server/src/modules/kyc/kyc.service.ts | 2 +- .../qualification/qualification.controller.ts | 2 +- .../qualification.service.spec.ts | 3 +- .../qualification/qualification.service.ts | 3 +- .../server/src/modules/user/fixtures/user.ts | 6 ++-- .../server/src/modules/user/index.ts | 2 +- .../server/src/modules/user/user.entity.ts | 17 ++------- .../src/modules/user/user.repository.ts | 5 +-- .../src/modules/user/user.service.spec.ts | 9 +++-- .../server/src/modules/user/user.service.ts | 3 +- 27 files changed, 77 insertions(+), 83 deletions(-) rename packages/apps/reputation-oracle/server/src/{modules/kyc/constants.ts => common/enums/user.ts} (53%) diff --git a/packages/apps/reputation-oracle/server/jest.config.ts b/packages/apps/reputation-oracle/server/jest.config.ts index e7de595d81..9d737bb3ca 100644 --- a/packages/apps/reputation-oracle/server/jest.config.ts +++ b/packages/apps/reputation-oracle/server/jest.config.ts @@ -1,4 +1,6 @@ -import { createDefaultPreset } from 'ts-jest'; +import { createDefaultPreset, pathsToModuleNameMapper } from 'ts-jest'; + +import { compilerOptions } from './tsconfig.json'; process.env['GIT_HASH'] = 'test_value_hardcoded_in_jest_config'; @@ -6,15 +8,12 @@ const jestTsPreset = createDefaultPreset({}); module.exports = { ...jestTsPreset, - coverageDirectory: '../coverage', - collectCoverageFrom: ['**/*.(t|j)s'], moduleFileExtensions: ['js', 'json', 'ts'], - rootDir: 'src', + roots: ['/src'], testEnvironment: 'node', testRegex: '.*\\.spec\\.ts$', - moduleNameMapper: { - '^uuid$': require.resolve('uuid'), - '^typeorm$': require.resolve('typeorm'), - }, + modulePaths: [compilerOptions.baseUrl], + + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths), clearMocks: true, }; diff --git a/packages/apps/reputation-oracle/server/src/common/decorators/index.ts b/packages/apps/reputation-oracle/server/src/common/decorators/index.ts index 93579ac151..6eceecf21c 100644 --- a/packages/apps/reputation-oracle/server/src/common/decorators/index.ts +++ b/packages/apps/reputation-oracle/server/src/common/decorators/index.ts @@ -1,6 +1,6 @@ import { Reflector } from '@nestjs/core'; -import { UserRole } from '@/modules/user'; +import { UserRole } from '@/common/enums'; /** * Decorator for HTTP endpoints to bypass JWT auth guard diff --git a/packages/apps/reputation-oracle/server/src/common/enums/index.ts b/packages/apps/reputation-oracle/server/src/common/enums/index.ts index 45fcd4ef6a..73ad1bf650 100644 --- a/packages/apps/reputation-oracle/server/src/common/enums/index.ts +++ b/packages/apps/reputation-oracle/server/src/common/enums/index.ts @@ -1,4 +1,5 @@ export * from './collection'; export * from './http'; export * from './manifest'; +export * from './user'; export * from './web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/constants.ts b/packages/apps/reputation-oracle/server/src/common/enums/user.ts similarity index 53% rename from packages/apps/reputation-oracle/server/src/modules/kyc/constants.ts rename to packages/apps/reputation-oracle/server/src/common/enums/user.ts index 0bfeebdb00..c280f79f55 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/constants.ts +++ b/packages/apps/reputation-oracle/server/src/common/enums/user.ts @@ -7,3 +7,15 @@ export enum KycStatus { EXPIRED = 'expired', ABANDONED = 'abandoned', } + +export enum UserStatus { + ACTIVE = 'active', + PENDING = 'pending', + INACTIVE = 'inactive', +} + +export enum UserRole { + OPERATOR = 'operator', + WORKER = 'worker', + ADMIN = 'admin', +} diff --git a/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts b/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts index b5fafb4f27..7a3aa5aa98 100644 --- a/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts +++ b/packages/apps/reputation-oracle/server/src/common/guards/roles.auth.ts @@ -8,8 +8,8 @@ import { import { Reflector } from '@nestjs/core'; import { Roles } from '@/common/decorators'; +import type { UserRole } from '@/common/enums'; import type { RequestWithUser } from '@/common/types'; -import type { UserRole } from '@/modules/user'; @Injectable() export class RolesAuthGuard implements CanActivate { diff --git a/packages/apps/reputation-oracle/server/src/database/database.module.ts b/packages/apps/reputation-oracle/server/src/database/database.module.ts index 7a77ad51c1..093c5d7abf 100644 --- a/packages/apps/reputation-oracle/server/src/database/database.module.ts +++ b/packages/apps/reputation-oracle/server/src/database/database.module.ts @@ -4,24 +4,23 @@ import { LoggerOptions } from 'typeorm'; import { SnakeNamingStrategy } from 'typeorm-naming-strategies'; import { DatabaseConfigService } from '@/config'; -import { AbuseEntity } from '@/modules/abuse'; -import { TokenEntity } from '@/modules/auth'; -import { CronJobEntity } from '@/modules/cron-job'; -import { - EscrowCompletionEntity, - EscrowPayoutsBatchEntity, -} from '@/modules/escrow-completion'; -import { KycEntity } from '@/modules/kyc'; -import { - QualificationEntity, - UserQualificationEntity, -} from '@/modules/qualification'; -import { ReputationEntity } from '@/modules/reputation'; -import { UserEntity, SiteKeyEntity } from '@/modules/user'; -import { - IncomingWebhookEntity, - OutgoingWebhookEntity, -} from '@/modules/webhook'; +/** + * Entities should be imported directly to avoid circular dependency + * between entity module and DB module + */ +import { AbuseEntity } from '@/modules/abuse/abuse.entity'; +import { TokenEntity } from '@/modules/auth/token.entity'; +import { CronJobEntity } from '@/modules/cron-job/cron-job.entity'; +import { EscrowCompletionEntity } from '@/modules/escrow-completion/escrow-completion.entity'; +import { EscrowPayoutsBatchEntity } from '@/modules/escrow-completion/escrow-payouts-batch.entity'; +import { KycEntity } from '@/modules/kyc/kyc.entity'; +import { QualificationEntity } from '@/modules/qualification/qualification.entity'; +import { UserQualificationEntity } from '@/modules/qualification/user-qualification.entity'; +import { ReputationEntity } from '@/modules/reputation/reputation.entity'; +import { SiteKeyEntity } from '@/modules/user/site-key.entity'; +import { UserEntity } from '@/modules/user/user.entity'; +import { IncomingWebhookEntity } from '@/modules/webhook/webhook-incoming.entity'; +import { OutgoingWebhookEntity } from '@/modules/webhook/webhook-outgoing.entity'; import { TypeOrmLoggerModule, TypeOrmLoggerService } from './typeorm'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts index 78d46ee8f8..8fe72fc2a0 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.spec.ts @@ -7,7 +7,7 @@ import { JwtModule, JwtService } from '@nestjs/jwt'; import { Test } from '@nestjs/testing'; import { omit } from 'lodash'; -import { SignatureType } from '@/common/enums'; +import { SignatureType, UserStatus, UserRole } from '@/common/enums'; import { AuthConfigService, NDAConfigService, @@ -16,13 +16,7 @@ import { } from '@/config'; import { EmailAction, EmailService } from '@/modules/email'; import { SiteKeyRepository } from '@/modules/user'; -import { - UserStatus, - UserRole, - UserEntity, - UserRepository, - UserService, -} from '@/modules/user'; +import { UserEntity, UserRepository, UserService } from '@/modules/user'; import { generateOperator, generateWorkerUser } from '@/modules/user/fixtures'; import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; import * as secutiryUtils from '@/utils/security'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts index cc84a67903..b116b089ae 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/auth.service.ts @@ -2,7 +2,7 @@ import { KVStoreKeys, KVStoreUtils, Role } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; -import { SignatureType } from '@/common/enums'; +import { SignatureType, UserRole, UserStatus } from '@/common/enums'; import { AuthConfigService, NDAConfigService, @@ -17,9 +17,7 @@ import { SiteKeyType, UserEntity, UserRepository, - UserRole, UserService, - UserStatus, type OperatorUserEntity, type Web2UserEntity, } from '@/modules/user'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts index 0059c952de..a09abf7419 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/dto/sign-up.dto.ts @@ -1,12 +1,12 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsEthereumAddress, IsString } from 'class-validator'; +import { UserRole } from '@/common/enums'; import { IsLowercasedEmail, IsLowercasedEnum, IsValidWeb3Signature, } from '@/common/validators'; -import { UserRole } from '@/modules/user'; import { ValidPassword } from './password.dto'; diff --git a/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts b/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts index 217c128ca2..d16695287f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts +++ b/packages/apps/reputation-oracle/server/src/modules/auth/jwt-http-strategy.ts @@ -8,8 +8,8 @@ import { LOGOUT_PATH, RESEND_EMAIL_VERIFICATION_PATH, } from '@/common/constants'; +import { UserRole, UserStatus } from '@/common/enums'; import { AuthConfigService } from '@/config'; -import { UserRole, UserStatus } from '@/modules/user'; @Injectable() export class JwtHttpStrategy extends PassportStrategy( diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts index e7eefe54b3..7f682841d7 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.module.ts @@ -3,7 +3,9 @@ import { Module } from '@nestjs/common'; import { ReputationModule } from '@/modules/reputation'; import { StorageModule } from '@/modules/storage'; import { Web3Module } from '@/modules/web3'; -// Using direct import instead of using index.ts due to the circular dependency +/** + * Import webhook-related items directly to avoid circular dependency + */ import { OutgoingWebhookModule } from '@/modules/webhook/webhook-outgoing.module'; import { EscrowCompletionRepository } from './escrow-completion.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts index 255c875d15..52413bef81 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts @@ -21,10 +21,11 @@ import logger from '@/logger'; import { ReputationService } from '@/modules/reputation'; import { StorageService } from '@/modules/storage'; import { Web3Service } from '@/modules/web3'; -import { - OutgoingWebhookService, - OutgoingWebhookEventType, -} from '@/modules/webhook'; +/** + * Import webhook-related items directly to avoid circular dependency + */ +import { OutgoingWebhookEventType } from '@/modules/webhook/types'; +import { OutgoingWebhookService } from '@/modules/webhook/webhook-outgoing.service'; import { calculateExponentialBackoffMs } from '@/utils/backoff'; import * as manifestUtils from '@/utils/manifest'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts index 922f64683e..13a4f7fab2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/fixtures/index.ts @@ -1,8 +1,8 @@ import { faker } from '@faker-js/faker'; +import { KycStatus } from '@/common/enums'; import { KycConfigService } from '@/config'; -import { KycStatus } from '../constants'; import { KycEntity } from '../kyc.entity'; export const mockKycConfigService: Omit = { diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts index 6c5760e234..4513ab68ea 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/index.ts @@ -1,3 +1,2 @@ export { KycModule } from './kyc.module'; export { KycEntity } from './kyc.entity'; -export { KycStatus } from './constants'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.dto.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.dto.ts index d8bde4ad57..5d83586f3f 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.dto.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.dto.ts @@ -8,7 +8,7 @@ import { ValidateNested, } from 'class-validator'; -import { KycStatus } from './constants'; +import { KycStatus } from '@/common/enums'; export class StartSessionResponseDto { @ApiProperty() diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts index 387cb34670..53eef5189b 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.entity.ts @@ -1,11 +1,10 @@ import { Column, Entity, JoinColumn, OneToOne } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { KycStatus } from '@/common/enums'; import { BaseEntity } from '@/database'; import type { UserEntity } from '@/modules/user'; -import { KycStatus } from './constants'; - @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'kycs' }) export class KycEntity extends BaseEntity { @Column({ type: 'varchar', unique: true, primary: true }) diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts index abe19b9496..ae6a1a8095 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.spec.ts @@ -4,6 +4,7 @@ import { HttpService } from '@nestjs/axios'; import { Test } from '@nestjs/testing'; import { ethers } from 'ethers'; +import { KycStatus } from '@/common/enums'; import { KycConfigService, Web3ConfigService } from '@/config'; import { UserRepository } from '@/modules/user'; import { generateWorkerUser } from '@/modules/user/fixtures'; @@ -15,7 +16,6 @@ import { createHttpServiceResponse, } from '~/test/mock-creators/nest'; -import { KycStatus } from './constants'; import { generateKycEntity, mockKycConfigService } from './fixtures'; import { UpdateKycStatusDto } from './kyc.dto'; import { KycEntity } from './kyc.entity'; diff --git a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts index c43867b988..9e31168992 100644 --- a/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/kyc/kyc.service.ts @@ -3,13 +3,13 @@ import { Injectable } from '@nestjs/common'; import { AxiosError } from 'axios'; import { catchError, firstValueFrom } from 'rxjs'; +import { KycStatus } from '@/common/enums'; import { KycConfigService, Web3ConfigService } from '@/config'; import logger from '@/logger'; import { UserNotFoundError, UserRepository } from '@/modules/user'; import { Web3Service } from '@/modules/web3'; import * as httpUtils from '@/utils/http'; -import { KycStatus } from './constants'; import { KycSignedAddressDto, UpdateKycStatusDto } from './kyc.dto'; import { KycEntity } from './kyc.entity'; import { KycErrorMessage, KycError } from './kyc.error'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts index e88f3123ff..ed9300d5d2 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.controller.ts @@ -18,8 +18,8 @@ import { } from '@nestjs/swagger'; import { Public, Roles } from '@/common/decorators'; +import { UserRole } from '@/common/enums'; import { RolesAuthGuard } from '@/common/guards'; -import { UserRole } from '@/modules/user'; import { AssignQualificationDto, diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts index 3c079a08c3..ca6939038e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.spec.ts @@ -3,8 +3,9 @@ import { createMock } from '@golevelup/ts-jest'; import { ConfigService } from '@nestjs/config'; import { Test } from '@nestjs/testing'; +import { UserStatus } from '@/common/enums'; import { ServerConfigService } from '@/config'; -import { UserStatus, UserRepository } from '@/modules/user'; +import { UserRepository } from '@/modules/user'; import { generateWorkerUser } from '@/modules/user/fixtures'; import { generateFutureDate } from '~/test/fixtures/date'; import { generateEthWallet } from '~/test/fixtures/web3'; diff --git a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts index 709cd5047a..ceae4d3249 100644 --- a/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/qualification/qualification.service.ts @@ -1,9 +1,10 @@ import { Injectable } from '@nestjs/common'; import { v4 as uuidV4 } from 'uuid'; +import { UserStatus } from '@/common/enums'; import { ServerConfigService } from '@/config'; import logger from '@/logger'; -import { UserRepository, UserStatus } from '@/modules/user'; +import { UserRepository } from '@/modules/user'; import { QualificationEntity } from './qualification.entity'; import { diff --git a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts index 7cd97eb5cb..d732c4020a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/fixtures/user.ts @@ -1,12 +1,12 @@ import { faker } from '@faker-js/faker'; import { SetNonNullable } from 'type-fest'; +import { UserRole, UserStatus } from '@/common/enums'; import * as securityUtils from '@/utils/security'; import * as web3Utils from '@/utils/web3'; import { generateEthWallet } from '~/test/fixtures/web3'; import { OperatorUserEntity, Web2UserEntity } from '../types'; -import { Role, UserStatus } from '../user.entity'; type Web2UserWithAddress = SetNonNullable; @@ -30,7 +30,7 @@ export function generateWorkerUser( email: faker.internet.email(), password: passwordHash, ndaSignedUrl: null, - role: Role.WORKER, + role: UserRole.WORKER, evmAddress: null, status: options?.status || UserStatus.ACTIVE, createdAt: faker.date.recent(), @@ -57,7 +57,7 @@ export function generateOperator( ): OperatorUserEntity { const user: OperatorUserEntity = { id: faker.number.int(), - role: Role.OPERATOR, + role: UserRole.OPERATOR, evmAddress: generateEthWallet(options?.privateKey).address.toLowerCase(), status: options?.status || UserStatus.ACTIVE, nonce: web3Utils.generateNonce(), diff --git a/packages/apps/reputation-oracle/server/src/modules/user/index.ts b/packages/apps/reputation-oracle/server/src/modules/user/index.ts index 7c9fc938db..faba2daf7b 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/index.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/index.ts @@ -1,7 +1,7 @@ export { SiteKeyRepository } from './site-key.repository'; export { SiteKeyType, SiteKeyEntity } from './site-key.entity'; export type * from './types'; -export { UserEntity, UserStatus, Role as UserRole } from './user.entity'; +export { UserEntity } from './user.entity'; export { UserNotFoundError } from './user.error'; export { UserModule } from './user.module'; export { UserRepository } from './user.repository'; diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts index 097a315ac2..d71a4453a3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.entity.ts @@ -2,24 +2,13 @@ import { Exclude } from 'class-transformer'; import { Column, Entity, OneToMany, OneToOne } from 'typeorm'; import { DATABASE_SCHEMA_NAME } from '@/common/constants'; +import { UserRole, UserStatus } from '@/common/enums'; import { BaseEntity } from '@/database'; import type { KycEntity } from '@/modules/kyc'; import type { UserQualificationEntity } from '@/modules/qualification'; import type { SiteKeyEntity } from './site-key.entity'; -export enum UserStatus { - ACTIVE = 'active', - PENDING = 'pending', - INACTIVE = 'inactive', -} - -export enum Role { - OPERATOR = 'operator', - WORKER = 'worker', - ADMIN = 'admin', -} - @Entity({ schema: DATABASE_SCHEMA_NAME, name: 'users' }) export class UserEntity extends BaseEntity { @Exclude() @@ -38,9 +27,9 @@ export class UserEntity extends BaseEntity { @Column({ type: 'enum', - enum: Role, + enum: UserRole, }) - role: Role; + role: UserRole; @Column({ type: 'varchar', diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts index b37ab62aec..a7560876c3 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.repository.ts @@ -1,9 +1,10 @@ import { Injectable } from '@nestjs/common'; import { DataSource, FindManyOptions, In } from 'typeorm'; +import { UserRole } from '@/common/enums'; import { BaseRepository } from '@/database'; -import { Role, UserEntity } from './user.entity'; +import { UserEntity } from './user.entity'; type FindOptions = { relations?: FindManyOptions['relations']; @@ -63,7 +64,7 @@ export class UserRepository extends BaseRepository { return this.find({ where: { - role: Role.WORKER, + role: UserRole.WORKER, evmAddress: In(lowercasedAddresses), }, }); diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts index 6dbe6385a1..be2744f64a 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.service.spec.ts @@ -6,9 +6,9 @@ import { KVStoreClient, KVStoreUtils } from '@human-protocol/sdk'; import { Test } from '@nestjs/testing'; import { SignatureType } from '@/common/enums'; +import { UserRole, KycStatus } from '@/common/enums'; import { Web3ConfigService } from '@/config'; import { HCaptchaService } from '@/integrations/hcaptcha/hcaptcha.service'; -import { KycStatus } from '@/modules/kyc'; import { generateKycEntity } from '@/modules/kyc/fixtures'; import { Web3Service } from '@/modules/web3'; import { mockWeb3ConfigService } from '@/modules/web3/fixtures'; @@ -22,7 +22,6 @@ import { } from './fixtures'; import { SiteKeyType } from './site-key.entity'; import { SiteKeyRepository } from './site-key.repository'; -import { Role } from './user.entity'; import { DuplicatedWalletAddressError, InvalidWeb3SignatureError, @@ -79,9 +78,9 @@ describe('UserService', () => { describe('isWeb2UserRole', () => { it.each( - Object.values(Role).map((role) => ({ + Object.values(UserRole).map((role) => ({ role, - result: role === Role.OPERATOR ? false : true, + result: role === UserRole.OPERATOR ? false : true, })), )('should return "$result" for "$role" role', ({ role, result }) => { expect(UserService.isWeb2UserRole(role)).toBe(result); @@ -96,7 +95,7 @@ describe('UserService', () => { it('should throw if not worker user', async () => { const user = generateWorkerUser(); - user.role = Role.ADMIN; + user.role = UserRole.ADMIN; mockUserRepository.findOneById.mockResolvedValueOnce(user); diff --git a/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts b/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts index 6a508276a1..331a6003c0 100644 --- a/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/user/user.service.ts @@ -2,16 +2,15 @@ import { KVStoreClient, KVStoreUtils } from '@human-protocol/sdk'; import { Injectable } from '@nestjs/common'; import { SignatureType } from '@/common/enums'; +import { KycStatus, UserRole } from '@/common/enums'; import { Web3ConfigService } from '@/config'; import { HCaptchaService } from '@/integrations/hcaptcha/hcaptcha.service'; -import { KycStatus } from '@/modules/kyc'; import { Web3Service } from '@/modules/web3'; import * as web3Utils from '@/utils/web3'; import { SiteKeyEntity, SiteKeyType } from './site-key.entity'; import { SiteKeyRepository } from './site-key.repository'; import { OperatorUserEntity, Web2UserEntity } from './types'; -import { Role as UserRole } from './user.entity'; import { DuplicatedWalletAddressError, InvalidWeb3SignatureError,