From b05a8e7e58866c8a8ed6a32b54e2967a067860ba Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Thu, 29 Feb 2024 12:59:16 +0100 Subject: [PATCH 01/10] Draft: ro finnish --- packages/apps/human-app/server/.env.example | 2 + packages/apps/human-app/server/Dockerfile | 12 + .../apps/human-app/server/docker-compose.yml | 18 + packages/apps/human-app/server/package.json | 12 +- .../apps/human-app/server/src/app.module.ts | 3 + .../src/common/config/cache-factory.config.ts | 20 ++ .../config/environment-config.service.ts | 6 + .../interface/oracle-discovery.interface.ts | 20 ++ .../job-discovery/job-discovery.controller.ts | 38 ++ .../job-discovery/job-discovery.mapper.ts | 21 ++ .../job-discovery/job-discovery.module.ts | 14 + .../job-discovery/job-discovery.serivce.ts | 51 +++ .../spec/job-discovery.controller.spec.ts | 0 .../spec/jobi-discovery.service.spec.ts | 0 yarn.lock | 325 ++++++++++++++++-- 15 files changed, 510 insertions(+), 32 deletions(-) create mode 100644 packages/apps/human-app/server/Dockerfile create mode 100644 packages/apps/human-app/server/docker-compose.yml create mode 100644 packages/apps/human-app/server/src/common/config/cache-factory.config.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/spec/job-discovery.controller.spec.ts create mode 100644 packages/apps/human-app/server/src/modules/job-discovery/spec/jobi-discovery.service.spec.ts diff --git a/packages/apps/human-app/server/.env.example b/packages/apps/human-app/server/.env.example index 8587caea67..9a1f74e42d 100644 --- a/packages/apps/human-app/server/.env.example +++ b/packages/apps/human-app/server/.env.example @@ -1,5 +1,7 @@ HOST= PORT= REPUTATION_ORACLE_URL= +REDIS_PORT= +REDIS_HOST= E2E_TESTING_EMAIL_ADDRESS= E2E_TESTING_PASSWORD= diff --git a/packages/apps/human-app/server/Dockerfile b/packages/apps/human-app/server/Dockerfile new file mode 100644 index 0000000000..d39ec93703 --- /dev/null +++ b/packages/apps/human-app/server/Dockerfile @@ -0,0 +1,12 @@ +FROM node:latest +LABEL authors="maciek.nabialek" +WORKDIR /app +COPY package.json yarn.lock ./ +COPY packages/apps/human-app/server ./packages/apps/human-app/server + +WORKDIR /app/packages/apps/human-app/server + +RUN yarn install --frozen-lockfile --ignore-scripts +RUN yarn build +EXPOSE 3000 +CMD ["yarn", "start"] diff --git a/packages/apps/human-app/server/docker-compose.yml b/packages/apps/human-app/server/docker-compose.yml new file mode 100644 index 0000000000..dced01d05a --- /dev/null +++ b/packages/apps/human-app/server/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.8' +services: + app: + build: + context: ../../../.. + dockerfile: packages/apps/human-app/server/Dockerfile + ports: + - "3000:3000" + depends_on: + - redis + environment: + - REDIS_HOST=redis + - REDIS_PORT=6379 + + redis: + image: redis:latest + ports: + - "6379:6379" diff --git a/packages/apps/human-app/server/package.json b/packages/apps/human-app/server/package.json index 33f96271bc..de90b7cd6f 100644 --- a/packages/apps/human-app/server/package.json +++ b/packages/apps/human-app/server/package.json @@ -23,33 +23,39 @@ "@automapper/classes": "^8.8.1", "@automapper/core": "^8.8.1", "@automapper/nestjs": "^8.8.1", + "@human-protocol/sdk": "^2.0.0", "@nestjs/axios": "^2.0.0", + "@nestjs/cache-manager": "^2.2.1", "@nestjs/common": "^10.2.7", "@nestjs/config": "^3.1.1", "@nestjs/core": "^10.2.8", "@nestjs/platform-express": "^10.2.6", "@nestjs/swagger": "^7.1.13", + "cache-manager": "^5.4.0", + "class-transformer": "^0.5.1", + "class-validator": "^0.14.1", "ethers": "^6.11.0", + "joi": "^17.12.2", "reflect-metadata": "^0.1.13", "rxjs": "^7.2.0" }, "devDependencies": { + "@nestjs/cache-manager": "^2.2.1", "@nestjs/cli": "^9.4.3", - "@nestjs/schematics": "^9.2.0", "@nestjs/testing": "^9.4.3", - "@types/express": "^4.17.13", "@types/jest": "29.5.1", "@types/node": "20.10.4", "@types/supertest": "^2.0.15", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", + "cache-manager-redis-store": "^3.0.1", "eslint": "^8.55.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.0.0", + "ioredis": "^5.3.2", "jest": "29.5.0", "nock": "^13.5.1", "prettier": "^3.1.1", - "source-map-support": "^0.5.20", "supertest": "^6.1.3", "ts-jest": "29.1.1", "ts-loader": "^9.2.3", diff --git a/packages/apps/human-app/server/src/app.module.ts b/packages/apps/human-app/server/src/app.module.ts index 1440fe8d2e..33390e8450 100644 --- a/packages/apps/human-app/server/src/app.module.ts +++ b/packages/apps/human-app/server/src/app.module.ts @@ -11,6 +11,8 @@ import { OperatorModule } from './modules/user-operator/operator.module'; import { OperatorController } from './modules/user-operator/operator.controller'; import { WorkerController } from './modules/user-worker/worker.controller'; import { CommonConfigModule } from './common/config/common-config.module'; +import { CacheFactoryConfig } from './common/config/cache-factory.config'; +import { CacheModule } from '@nestjs/cache-manager'; @Module({ imports: [ @@ -22,6 +24,7 @@ import { CommonConfigModule } from './common/config/common-config.module'; AutomapperModule.forRoot({ strategyInitializer: classes(), }), + CacheModule.registerAsync(CacheFactoryConfig), HttpModule, WorkerModule, OperatorModule, diff --git a/packages/apps/human-app/server/src/common/config/cache-factory.config.ts b/packages/apps/human-app/server/src/common/config/cache-factory.config.ts new file mode 100644 index 0000000000..278680dfcc --- /dev/null +++ b/packages/apps/human-app/server/src/common/config/cache-factory.config.ts @@ -0,0 +1,20 @@ +import { CacheModuleAsyncOptions } from '@nestjs/common/cache'; +import { ConfigModule } from '@nestjs/config'; +import { EnvironmentConfigService } from './environment-config.service'; +import { redisStore } from 'cache-manager-redis-store'; +export const CacheFactoryConfig: CacheModuleAsyncOptions = { + isGlobal: true, + imports: [ConfigModule], + useFactory: async (configService: EnvironmentConfigService) => { + const store = await redisStore({ + socket: { + host: configService.cacheHost, + port: configService.cachePort, + }, + }); + return { + store: () => store, + }; + }, + inject: [EnvironmentConfigService], +}; diff --git a/packages/apps/human-app/server/src/common/config/environment-config.service.ts b/packages/apps/human-app/server/src/common/config/environment-config.service.ts index 2ebf782fca..0cea45491d 100644 --- a/packages/apps/human-app/server/src/common/config/environment-config.service.ts +++ b/packages/apps/human-app/server/src/common/config/environment-config.service.ts @@ -14,6 +14,12 @@ export class EnvironmentConfigService { get reputationOracleUrl(): string { return this.configService.get('REPUTATION_ORACLE_URL', ''); } + get cachePort(): number { + return this.configService.get('REDIS_PORT', 6379); + } + get cacheHost(): string { + return this.configService.get('REDIS_HOST', 'localhost'); + } } export const envValidator = Joi.object({ diff --git a/packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts b/packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts new file mode 100644 index 0000000000..8d51d23c12 --- /dev/null +++ b/packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts @@ -0,0 +1,20 @@ +import { ChainId, IOperator } from '@human-protocol/sdk'; +export class OracleDiscoveryDto { + chainId: ChainId; + address: string; + role: string; +} +export class OracleDiscoveryCommand { + chainId: ChainId; + address: string; + role: string; +} + +export class OracleDiscoveryData implements IOperator { + address: string; + role?: string; + constructor(address: string, role: string) { + this.address = address; + this.role = role; + } +} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts new file mode 100644 index 0000000000..31e52098a1 --- /dev/null +++ b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts @@ -0,0 +1,38 @@ +import { + Body, + Controller, + Get, + UsePipes, + ValidationPipe, +} from '@nestjs/common'; +import { Mapper } from '@automapper/core'; +import { InjectMapper } from '@automapper/nestjs'; +import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { JobDiscoveryService } from './job-discovery.serivce'; +import { + OracleDiscoveryCommand, + OracleDiscoveryData, + OracleDiscoveryDto, +} from './interface/oracle-discovery.interface'; + +@Controller() +export class JobDiscoveryController { + constructor( + private readonly service: JobDiscoveryService, + @InjectMapper() private readonly mapper: Mapper, + ) {} + @ApiTags('Oracle-Discovery') + @Get('/oracles') + @ApiOperation({ summary: 'Operator signup' }) + @UsePipes(new ValidationPipe()) + public signupOperator( + @Body() oracleDiscoveryDto: OracleDiscoveryDto, + ): Promise { + const oracleDiscoveryCommand = this.mapper.map( + oracleDiscoveryDto, + OracleDiscoveryDto, + OracleDiscoveryCommand, + ); + return this.service.processOracleDiscovery(oracleDiscoveryCommand); + } +} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts new file mode 100644 index 0000000000..213d7ec71a --- /dev/null +++ b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@nestjs/common'; +import { AutomapperProfile, InjectMapper } from '@automapper/nestjs'; +import { createMap, Mapper } from '@automapper/core'; +import { + OracleDiscoveryCommand, + OracleDiscoveryData, + OracleDiscoveryDto, +} from './interface/oracle-discovery.interface'; + +@Injectable() +export class JobDiscoveryProfile extends AutomapperProfile { + constructor(@InjectMapper() mapper: Mapper) { + super(mapper); + } + + override get profile() { + return (mapper: Mapper) => { + createMap(mapper, OracleDiscoveryDto, OracleDiscoveryCommand); + }; + } +} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts new file mode 100644 index 0000000000..3e785b807f --- /dev/null +++ b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts @@ -0,0 +1,14 @@ +import { Module } from '@nestjs/common'; +import { ReputationOracleModule } from '../../integrations/reputation-oracle/reputation-oracle.module'; +import { OperatorService } from '../user-operator/operator.service'; +import { OperatorProfile } from '../user-operator/operator.mapper'; +import { JobDiscoveryController } from './job-discovery.controller'; +import { JobDiscoveryService } from './job-discovery.serivce'; +import { JobDiscoveryProfile } from './job-discovery.mapper'; + +@Module({ + controllers: [JobDiscoveryController], + providers: [JobDiscoveryService, JobDiscoveryProfile], + exports: [JobDiscoveryController, JobDiscoveryService], +}) +export class JobDiscoveryModule {} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts new file mode 100644 index 0000000000..be1229d94c --- /dev/null +++ b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts @@ -0,0 +1,51 @@ +import { Inject, Injectable } from '@nestjs/common'; +import { ReputationOracleGateway } from '../../integrations/reputation-oracle/reputation-oracle.gateway'; +import { + OracleDiscoveryCommand, + OracleDiscoveryData, +} from './interface/oracle-discovery.interface'; +import { CACHE_MANAGER } from '@nestjs/cache-manager'; +import { Cache } from 'cache-manager'; +import { IOperator, OperatorUtils } from '@human-protocol/sdk'; + +@Injectable() +export class JobDiscoveryService { + static readonly TTL_1_DAY = 24 * 60 * 60; + constructor( + private reputationOracleGateway: ReputationOracleGateway, + @Inject(CACHE_MANAGER) private cacheManager: Cache, + ) {} + + async processOracleDiscovery( + command: OracleDiscoveryCommand, + ): Promise { + const cachedData: OracleDiscoveryData[] | undefined = + await this.cacheManager.get(command.address); + if (cachedData) { + return cachedData; + } + const data: IOperator[] = + await this.getOperatorsForOracleDiscovery(command); + await this.setOperatorsForAddress(command.address, data); + return data; + } + getOperatorsForOracleDiscovery = ( + cmd: OracleDiscoveryCommand, + ): Promise => { + return OperatorUtils.getReputationNetworkOperators( + cmd.chainId, + cmd.address, + cmd.role, + ); + }; + setOperatorsForAddress = ( + address: string, + operators: OracleDiscoveryData[], + ): Promise => { + return this.cacheManager.set( + address, + operators, + JobDiscoveryService.TTL_1_DAY, + ); + }; +} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/spec/job-discovery.controller.spec.ts b/packages/apps/human-app/server/src/modules/job-discovery/spec/job-discovery.controller.spec.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/apps/human-app/server/src/modules/job-discovery/spec/jobi-discovery.service.spec.ts b/packages/apps/human-app/server/src/modules/job-discovery/spec/jobi-discovery.service.spec.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/yarn.lock b/yarn.lock index e23624f42a..dccf2fc1fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2813,12 +2813,12 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@hapi/hoek@^9.0.0": +"@hapi/hoek@^9.0.0", "@hapi/hoek@^9.3.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ== -"@hapi/topo@^5.0.0": +"@hapi/topo@^5.0.0", "@hapi/topo@^5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012" integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg== @@ -2838,6 +2838,24 @@ "@babel/runtime" "^7.17.9" "@hcaptcha/loader" "^1.2.1" +"@human-protocol/sdk@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@human-protocol/sdk/-/sdk-2.0.0.tgz#320eb46cc7045627e42576e22cedf1a05ff49916" + integrity sha512-ZVwZlLIeUnbaeehp79E+vFNJK6ptT1N98GWQ6Pyri88LvDoETWvAmffkMiO+tmDyuuxGebmhB+DpegTtrdHOwQ== + dependencies: + "@human-protocol/core" "*" + aws-sdk "^2.1528.0" + axios "^1.4.0" + crypto "^1.0.1" + graphql "^16.8.1" + graphql-request "^6.1.0" + graphql-tag "^2.12.6" + minio "^7.0.32" + openpgp "^5.10.2" + secp256k1 "^4.0.3" + vitest "^0.30.1" + winston "^3.8.2" + "@humanwhocodes/config-array@^0.11.13": version "0.11.13" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.13.tgz#075dc9684f40a531d9b26b0822153c1e832ee297" @@ -2956,7 +2974,7 @@ jest-util "^29.7.0" slash "^3.0.0" -"@jest/core@^29.7.0": +"@jest/core@^29.5.0", "@jest/core@^29.7.0": version "29.7.0" resolved "https://registry.yarnpkg.com/@jest/core/-/core-29.7.0.tgz#b6cccc239f30ff36609658c5a5e2291757ce448f" integrity sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg== @@ -3124,7 +3142,7 @@ slash "^3.0.0" write-file-atomic "^4.0.2" -"@jest/types@^29.6.3": +"@jest/types@^29.5.0", "@jest/types@^29.6.3": version "29.6.3" resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== @@ -3497,6 +3515,11 @@ resolved "https://registry.yarnpkg.com/@nestjs/axios/-/axios-2.0.0.tgz#2116fad483e232ef102a877b503a9f19926bd102" integrity sha512-F6oceoQLEn031uun8NiommeMkRIojQqVryxQy/mK7fx0CI0KbgkJL3SloCQcsOD+agoEnqKJKXZpEvL6FNswJg== +"@nestjs/cache-manager@^2.2.1": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@nestjs/cache-manager/-/cache-manager-2.2.1.tgz#848bfa2e30066a00cc6100291639d2c3191330cf" + integrity sha512-mXj0zenuyMPJICokwVud4Kjh0+pzBNBAgfpx3I48LozNkd8Qfv/MAhZsb15GihGpbFRxafUo3p6XvtAqRm8GRw== + "@nestjs/cli@^9.4.3": version "9.5.0" resolved "https://registry.yarnpkg.com/@nestjs/cli/-/cli-9.5.0.tgz#ddf1b0e21b5507c151e0cd1a4cfcf6c55df7cb2e" @@ -3636,6 +3659,13 @@ dependencies: tslib "2.6.2" +"@nestjs/testing@^9.4.3": + version "9.4.3" + resolved "https://registry.yarnpkg.com/@nestjs/testing/-/testing-9.4.3.tgz#53ffbabdd38f500b145c30f2fbb76dedad393d79" + integrity sha512-LDT8Ai2eKnTzvnPaJwWOK03qTaFap5uHHsJCv6dL0uKWk6hyF9jms8DjyVaGsaujCaXDG8izl1mDEER0OmxaZA== + dependencies: + tslib "2.5.3" + "@nestjs/typeorm@^10.0.1": version "10.0.1" resolved "https://registry.yarnpkg.com/@nestjs/typeorm/-/typeorm-10.0.1.tgz#0b5c36c21a06c274f9d283e73988b887e7f0635b" @@ -4703,6 +4733,40 @@ resolved "https://registry.yarnpkg.com/@react-dnd/shallowequal/-/shallowequal-3.0.1.tgz#8056fe046a8d10a275e321ec0557ae652d7a4d06" integrity sha512-XjDVbs3ZU16CO1h5Q3Ew2RPJqmZBDE/EVf1LYp6ePEffs3V/MX9ZbL5bJr8qiK5SbGmUMuDoaFgyKacYz8prRA== +"@redis/bloom@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@redis/bloom/-/bloom-1.2.0.tgz#d3fd6d3c0af3ef92f26767b56414a370c7b63b71" + integrity sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg== + +"@redis/client@1.5.14": + version "1.5.14" + resolved "https://registry.yarnpkg.com/@redis/client/-/client-1.5.14.tgz#1107893464d092f140d77c468b018a6ed306a180" + integrity sha512-YGn0GqsRBFUQxklhY7v562VMOP0DcmlrHHs3IV1mFE3cbxe31IITUkqhBcIhVSI/2JqtWAJXg5mjV4aU+zD0HA== + dependencies: + cluster-key-slot "1.1.2" + generic-pool "3.9.0" + yallist "4.0.0" + +"@redis/graph@1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@redis/graph/-/graph-1.1.1.tgz#8c10df2df7f7d02741866751764031a957a170ea" + integrity sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw== + +"@redis/json@1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@redis/json/-/json-1.0.6.tgz#b7a7725bbb907765d84c99d55eac3fcf772e180e" + integrity sha512-rcZO3bfQbm2zPRpqo82XbW8zg4G/w4W3tI7X8Mqleq9goQjAGLL7q/1n1ZX4dXEAmORVZ4s1+uKLaUOg7LrUhw== + +"@redis/search@1.1.6": + version "1.1.6" + resolved "https://registry.yarnpkg.com/@redis/search/-/search-1.1.6.tgz#33bcdd791d9ed88ab6910243a355d85a7fedf756" + integrity sha512-mZXCxbTYKBQ3M2lZnEddwEAks0Kc7nauire8q20oA0oA/LoA+E/b5Y5KZn232ztPb1FkIGqo12vh3Lf+Vw5iTw== + +"@redis/time-series@1.0.5": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@redis/time-series/-/time-series-1.0.5.tgz#a6d70ef7a0e71e083ea09b967df0a0ed742bc6ad" + integrity sha512-IFjIgTusQym2B5IZJG3XKr5llka7ey84fw/NOYqESP5WUfQs9zz1ww/9+qoz4ka/S6KcGBodzlCeZ5UImKbscg== + "@reduxjs/toolkit@1.9.7", "@reduxjs/toolkit@^1.9.0", "@reduxjs/toolkit@^1.9.5": version "1.9.7" resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.9.7.tgz#7fc07c0b0ebec52043f8cb43510cf346405f78a6" @@ -5110,6 +5174,13 @@ dependencies: "@hapi/hoek" "^9.0.0" +"@sideway/address@^4.1.5": + version "4.1.5" + resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.5.tgz#4bc149a0076623ced99ca8208ba780d65a99b9d5" + integrity sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q== + dependencies: + "@hapi/hoek" "^9.0.0" + "@sideway/formula@^3.0.1": version "3.0.1" resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.1.tgz#80fcbcbaf7ce031e0ef2dd29b1bfc7c3f583611f" @@ -6564,6 +6635,14 @@ dependencies: "@types/istanbul-lib-report" "*" +"@types/jest@29.5.1": + version "29.5.1" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.1.tgz#83c818aa9a87da27d6da85d3378e5a34d2f31a47" + integrity sha512-tEuVcHrpaixS36w7hpsfLBLpjtMRJUE09/MHXn923LOVojDwyC14cWcfc0rDs0VEfUyYmt/+iX1kxxp+gZMcaQ== + dependencies: + expect "^29.0.0" + pretty-format "^29.0.0" + "@types/jest@29.5.11", "@types/jest@^29.5.11": version "29.5.11" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.11.tgz#0c13aa0da7d0929f078ab080ae5d4ced80fa2f2c" @@ -6691,6 +6770,13 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== +"@types/node@20.10.4": + version "20.10.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.4.tgz#b246fd84d55d5b1b71bf51f964bd514409347198" + integrity sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg== + dependencies: + undici-types "~5.26.4" + "@types/node@^10.0.3": version "10.17.60" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" @@ -6871,6 +6957,15 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== +"@types/superagent@*": + version "8.1.4" + resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-8.1.4.tgz#f8290d1b7d6081f84f3047851c190c4a3c8cdb21" + integrity sha512-uzSBYwrpal8y2X2Pul5ZSWpzRiDha2FLcquaN95qUPnOjYgm/zQ5LIdqeJpQJTRWNTN+Rhm0aC8H06Ds2rqCYw== + dependencies: + "@types/cookiejar" "^2.1.5" + "@types/methods" "^1.1.4" + "@types/node" "*" + "@types/superagent@^8.1.0": version "8.1.1" resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-8.1.1.tgz#dbc620c5df3770b0c3092f947d6d5e808adae2bc" @@ -6880,6 +6975,13 @@ "@types/methods" "^1.1.4" "@types/node" "*" +"@types/supertest@^2.0.15": + version "2.0.16" + resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-2.0.16.tgz#7a1294edebecb960d957bbe9b26002a2b7f21cd7" + integrity sha512-6c2ogktZ06tr2ENoZivgm7YnprnhYE4ZoXGMY+oA7IuAf17M8FWvujXZGmxLv8y0PTyts4x5A+erSwVUFA8XSg== + dependencies: + "@types/superagent" "*" + "@types/supertest@^6.0.2": version "6.0.2" resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-6.0.2.tgz#2af1c466456aaf82c7c6106c6b5cbd73a5e86588" @@ -8567,7 +8669,7 @@ async-retry@^1.3.3: dependencies: retry "0.13.1" -async@1.x: +async@1.5.2, async@1.x: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" integrity sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w== @@ -9000,6 +9102,11 @@ blockstore-core@^1.0.2: it-take "^1.0.1" multiformats "^9.4.7" +bluebird@^3.4.6: + version "3.7.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" + integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== + blueimp-md5@^2.10.0: version "2.19.0" resolved "https://registry.yarnpkg.com/blueimp-md5/-/blueimp-md5-2.19.0.tgz#b53feea5498dcb53dc6ec4b823adb84b729c4af0" @@ -9461,6 +9568,40 @@ cache-content-type@^1.0.0: mime-types "^2.1.18" ylru "^1.2.0" +cache-manager-redis-store@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/cache-manager-redis-store/-/cache-manager-redis-store-3.0.1.tgz#8eeb211212763d04cef4058666182d624f714299" + integrity sha512-o560kw+dFqusC9lQJhcm6L2F2fMKobJ5af+FoR2PdnMVdpQ3f3Bz6qzvObTGyvoazQJxjQNWgMQeChP4vRTuXQ== + dependencies: + redis "^4.3.1" + +cache-manager-redis@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/cache-manager-redis/-/cache-manager-redis-0.6.0.tgz#b364b8e855b287edae1b07780addb9bc9860ebce" + integrity sha512-i7grsVyuIppLyzKAAHM48Eo2YX51+D++Pp1MQiX/9GCBVr3ofayiBpLrz/k/IUpaU9HUZ56P+v5Ee7yJRkfk/w== + dependencies: + cache-manager "^2.2.0" + redis-url "^1.2.1" + sol-redis-pool "^0.3.2" + +cache-manager@^2.2.0: + version "2.11.1" + resolved "https://registry.yarnpkg.com/cache-manager/-/cache-manager-2.11.1.tgz#212e8c3db15288af653b029a1d9fe12f1fd9df61" + integrity sha512-XhUuc9eYwkzpK89iNewFwtvcDYMUsvtwzHeyEOPJna/WsVsXcrzsA1ft2M0QqPNunEzLhNCYPo05tEfG+YuNow== + dependencies: + async "1.5.2" + lodash.clonedeep "4.5.0" + lru-cache "4.0.0" + +cache-manager@^5.4.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/cache-manager/-/cache-manager-5.4.0.tgz#cec47dbea8e49e0f6970d117be10172b4e621358" + integrity sha512-FS7o8vqJosnLpu9rh2gQTo8EOzCRJLF1BJ4XDEUDMqcfvs7SJZs5iuoFTXLauzQ3S5v8sBAST1pCwMaurpyi1A== + dependencies: + lodash.clonedeep "^4.5.0" + lru-cache "^10.1.0" + promise-coalesce "^1.1.2" + cacheable-lookup@^5.0.3: version "5.0.4" resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" @@ -10042,7 +10183,7 @@ clsx@^2.0.0: resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.1.0.tgz#e851283bcb5c80ee7608db18487433f7b23f77cb" integrity sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg== -cluster-key-slot@^1.1.0: +cluster-key-slot@1.1.2, cluster-key-slot@^1.1.0: version "1.1.2" resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz#88ddaa46906e303b5de30d3153b7d9fe0a0c19ac" integrity sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA== @@ -11633,7 +11774,14 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== -ejs@3.1.8, ejs@^3.1.8: +ejs@3.1.6: + version "3.1.6" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.6.tgz#5bfd0a0689743bb5268b3550cceeebbc1702822a" + integrity sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw== + dependencies: + jake "^10.6.1" + +ejs@^3.1.8: version "3.1.9" resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.9.tgz#03c9e8777fe12686a9effcef22303ca3d8eeb361" integrity sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ== @@ -12707,10 +12855,6 @@ ethers@^6.11.0: tslib "2.4.0" ws "8.5.0" -ethers@^6.8.1: - version "6.9.0" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.9.0.tgz#a4534bdcdfde306aee94ef32f3d5c70d7e33fcb9" - integrity sha512-pmfNyQzc2mseLe91FnT2vmNaTt8dDzhxZ/xItAV7uGsF4dI4ek2ufMu3rAkgQETL/TIs0GS5A+U05g9QyWnv3Q== ethers@^6.8.1, ethers@^6.9.1: version "6.9.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.9.2.tgz#6f4632f62e2350fa8354ff28624027a175ef85a4" @@ -13577,6 +13721,16 @@ gauge@^3.0.0: strip-ansi "^6.0.1" wide-align "^1.1.2" +generic-pool@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-2.2.1.tgz#750ac994eca4e7f87f616e2adff0253f64659ad6" + integrity sha512-nhvlRRwPMl04jnZOEB4Myh8NwNfWpgBbS2IXzdZBdTM7Udvw1/qSCzxd/9P4EanohUzTgNath7v7KQFlOd2W2Q== + +generic-pool@3.9.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-3.9.0.tgz#36f4a678e963f4fdb8707eab050823abc4e8f5e4" + integrity sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g== + gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" @@ -13935,10 +14089,10 @@ globby@^13.1.2: merge2 "^1.4.1" slash "^4.0.0" -gluegun@5.1.2, gluegun@^5.0.0: - version "5.1.6" - resolved "https://registry.yarnpkg.com/gluegun/-/gluegun-5.1.6.tgz#74ec13193913dc610f5c1a4039972c70c96a7bad" - integrity sha512-9zbi4EQWIVvSOftJWquWzr9gLX2kaDgPkNR5dYWbM53eVvCI3iKuxLlnKoHC0v4uPoq+Kr/+F569tjoFbA4DSA== +gluegun@5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/gluegun/-/gluegun-5.1.2.tgz#ffa0beda0fb6bbc089a867157b08602beae2c8cf" + integrity sha512-Cwx/8S8Z4YQg07a6AFsaGnnnmd8mN17414NcPS3OoDtZRwxgsvwRNJNg69niD6fDa8oNwslCG0xH7rEpRNNE/g== dependencies: apisauce "^2.1.5" app-module-path "^2.2.0" @@ -13946,7 +14100,7 @@ gluegun@5.1.2, gluegun@^5.0.0: colors "1.4.0" cosmiconfig "7.0.1" cross-spawn "7.0.3" - ejs "3.1.8" + ejs "3.1.6" enquirer "2.3.6" execa "5.1.1" fs-jetpack "4.3.1" @@ -15918,7 +16072,7 @@ jackspeak@^2.3.5: optionalDependencies: "@pkgjs/parseargs" "^0.11.0" -jake@^10.8.5: +jake@^10.6.1, jake@^10.8.5: version "10.8.7" resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.7.tgz#63a32821177940c33f356e0ba44ff9d34e1c7d8f" integrity sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w== @@ -15999,7 +16153,7 @@ jest-circus@^29.7.0: slash "^3.0.0" stack-utils "^2.0.3" -jest-cli@^29.7.0: +jest-cli@^29.5.0, jest-cli@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-29.7.0.tgz#5592c940798e0cae677eec169264f2d839a37995" integrity sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg== @@ -16335,6 +16489,16 @@ jest-worker@^29.7.0: merge-stream "^2.0.0" supports-color "^8.0.0" +jest@29.5.0: + version "29.5.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-29.5.0.tgz#f75157622f5ce7ad53028f2f8888ab53e1f1f24e" + integrity sha512-juMg3he2uru1QoXX078zTa7pO85QyB9xajZc6bU+d9yEGwrKX6+vGmJQ3UdVZsvTEUARIdObzH68QItim6OSSQ== + dependencies: + "@jest/core" "^29.5.0" + "@jest/types" "^29.5.0" + import-local "^3.0.2" + jest-cli "^29.5.0" + jest@29.7.0, jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest/-/jest-29.7.0.tgz#994676fc24177f088f1c5e3737f5697204ff2613" @@ -16360,6 +16524,17 @@ jmespath@0.16.0: resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076" integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw== +joi@^17.12.2: + version "17.12.2" + resolved "https://registry.yarnpkg.com/joi/-/joi-17.12.2.tgz#283a664dabb80c7e52943c557aab82faea09f521" + integrity sha512-RonXAIzCiHLc8ss3Ibuz45u28GOsWE1UpfDXLbN/9NKbL4tCJf8TWYVKsoYuuh+sAUt7fsSNpA+r2+TBA6Wjmw== + dependencies: + "@hapi/hoek" "^9.3.0" + "@hapi/topo" "^5.1.0" + "@sideway/address" "^4.1.5" + "@sideway/formula" "^3.0.1" + "@sideway/pinpoint" "^2.0.0" + joi@^17.9.2: version "17.11.0" resolved "https://registry.yarnpkg.com/joi/-/joi-17.11.0.tgz#aa9da753578ec7720e6f0ca2c7046996ed04fc1a" @@ -17209,7 +17384,7 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== -lodash.clonedeep@^4.5.0: +lodash.clonedeep@4.5.0, lodash.clonedeep@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== @@ -17489,11 +17664,24 @@ lowercase-keys@^2.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== +lru-cache@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.0.tgz#b5cbf01556c16966febe54ceec0fb4dc90df6c28" + integrity sha512-WKhDkjlLwzE8jAQdQlsxLUQTPXLCKX/4cJk6s5AlRtJkDBk0IKH5O51bVDH61K9N4bhbbyvLM6EiOuE8ovApPA== + dependencies: + pseudomap "^1.0.1" + yallist "^2.0.0" + lru-cache@^10.0.2, "lru-cache@^9.1.1 || ^10.0.0": version "10.1.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.1.0.tgz#2098d41c2dc56500e6c88584aa656c84de7d0484" integrity sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag== +lru-cache@^10.1.0: + version "10.2.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.0.tgz#0bd445ca57363465900f4d1f9bd8db343a4d95c3" + integrity sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -18515,7 +18703,7 @@ node-fetch@2.7.0, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node dependencies: whatwg-url "^5.0.0" -node-forge@^1.0.0, node-forge@^1.3.1: +node-forge@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== @@ -19881,7 +20069,7 @@ prettier@^2.3.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== -prettier@^3.2.5: +prettier@^3.1.1, prettier@^3.2.5: version "3.2.5" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== @@ -19935,6 +20123,11 @@ progress-stream@^2.0.0: speedometer "~1.0.0" through2 "~2.0.3" +promise-coalesce@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/promise-coalesce/-/promise-coalesce-1.1.2.tgz#5d3bc4d0b2cf2e41e9df7cbeb6519b2a09459e3d" + integrity sha512-zLaJ9b8hnC564fnJH6NFSOGZYYdzrAJn2JUUIwzoQb32fG2QAakpDNM+CZo1km6keXkRXRM+hml1BFAPVnPkxg== + promise@^8.0.0: version "8.3.0" resolved "https://registry.yarnpkg.com/promise/-/promise-8.3.0.tgz#8cb333d1edeb61ef23869fbb8a4ea0279ab60e0a" @@ -20025,6 +20218,11 @@ proxy-from-env@^1.1.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== +pseudomap@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== + psl@^1.1.28, psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" @@ -20101,7 +20299,7 @@ pvutils@^1.1.3: resolved "https://registry.yarnpkg.com/pvutils/-/pvutils-1.1.3.tgz#f35fc1d27e7cd3dfbd39c0826d173e806a03f5a3" integrity sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ== -qrcode@1.5.3, qrcode@^1.5.0, qrcode@^1.5.1: +qrcode@1.5.3, qrcode@^1.5.1: version "1.5.3" resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.5.3.tgz#03afa80912c0dccf12bc93f615a535aad1066170" integrity sha512-puyri6ApkEHYiVl4CFzo1tDkAZ+ATcnbJrJ6RiBM1Fhctdn/ix9MTE3hRph33omisEbC/2fcfemsseiKgBPKZg== @@ -20737,6 +20935,25 @@ redis-parser@^3.0.0: dependencies: redis-errors "^1.0.0" +redis-url@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/redis-url/-/redis-url-1.2.1.tgz#18670095a38e989d379359dd4c6e4abff85e2eb1" + integrity sha512-KL+/sxJXNecWSpRZj4MhRFXkfzG9Mip62x5BDNLIaN87JtdyWHHbm09qGiSfMr5yjhKeHLju79hgSCoi1WcYRg== + dependencies: + redis ">= 0.0.1" + +"redis@>= 0.0.1", "redis@>= 2.6.2", redis@^4.3.1: + version "4.6.13" + resolved "https://registry.yarnpkg.com/redis/-/redis-4.6.13.tgz#e247267c5f3ba35ab8277b57343d3a56acb2f0a6" + integrity sha512-MHgkS4B+sPjCXpf+HfdetBwbRz6vCtsceTmw1pHNYJAsYxrfpOP6dz+piJWGos8wqG7qb3vj/Rrc5qOlmInUuA== + dependencies: + "@redis/bloom" "1.2.0" + "@redis/client" "1.5.14" + "@redis/graph" "1.1.1" + "@redis/json" "1.0.6" + "@redis/search" "1.1.6" + "@redis/time-series" "1.0.5" + reduce-flatten@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" @@ -21451,7 +21668,38 @@ secp256k1@^4.0.1, secp256k1@^4.0.3: node-addon-api "^2.0.0" node-gyp-build "^4.2.0" -"semver@2 || 3 || 4 || 5", semver@7.3.5, semver@7.4.0, semver@7.5.4, semver@^5.5.0, semver@^6.0.0, semver@^6.3.0, semver@^6.3.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4: +"semver@2 || 3 || 4 || 5", semver@^5.5.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + +semver@7.3.5: + version "7.3.5" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" + integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== + dependencies: + lru-cache "^6.0.0" + +semver@7.4.0: + version "7.4.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.4.0.tgz#8481c92feffc531ab1e012a8ffc15bdd3a0f4318" + integrity sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw== + dependencies: + lru-cache "^6.0.0" + +semver@7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +semver@^6.0.0, semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== + +semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4: version "7.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== @@ -21869,6 +22117,15 @@ snapdragon@^0.8.1: source-map-resolve "^0.5.0" use "^3.1.0" +sol-redis-pool@^0.3.2: + version "0.3.3" + resolved "https://registry.yarnpkg.com/sol-redis-pool/-/sol-redis-pool-0.3.3.tgz#a7111d6f8942413ba0ad4733566167052db74a6b" + integrity sha512-sDXjqFOPVu/e3k0G0l7ECJ0V4Hm51ECyZYOPah1uYigJve3IUenj/y9tAw2o9mr4ORLbcMRIaw4ovn+RgXMnZA== + dependencies: + bluebird "^3.4.6" + generic-pool "2.2.1" + redis ">= 2.6.2" + solc@0.7.3: version "0.7.3" resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a" @@ -22513,7 +22770,7 @@ superstruct@^1.0.3: resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-1.0.3.tgz#de626a5b49c6641ff4d37da3c7598e7a87697046" integrity sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg== -supertest@^6.3.4: +supertest@^6.1.3, supertest@^6.3.4: version "6.3.4" resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.3.4.tgz#2145c250570c2ea5d337db3552dbfb78a2286218" integrity sha512-erY3HFDG0dPnhw4U+udPfrzXa4xhSG+n4rxfRuZWCUvjFWwKl+OxWf/7zk50s84/fAAs7vf5QAb9uRa0cCykxw== @@ -23217,6 +23474,11 @@ tslib@2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tslib@2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.3.tgz#24944ba2d990940e6e982c4bea147aba80209913" + integrity sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w== + tslib@2.6.2, tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.4.1, tslib@^2.5.0, tslib@^2.6.0, tslib@^2.6.1, tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" @@ -24923,16 +25185,21 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +yallist@4.0.0, yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yallist@^2.0.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A== + yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - yaml@1.10.2, yaml@^1.10.0, yaml@^1.10.2, yaml@^1.7.2: version "1.10.2" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" From dc83c9182d94ae7be42758e1ddf90e6c5150ab9e Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Thu, 29 Feb 2024 16:44:46 +0100 Subject: [PATCH 02/10] removes, unnecessary docker related files --- packages/apps/human-app/server/Dockerfile | 12 ------------ .../apps/human-app/server/docker-compose.yml | 18 ------------------ 2 files changed, 30 deletions(-) delete mode 100644 packages/apps/human-app/server/Dockerfile delete mode 100644 packages/apps/human-app/server/docker-compose.yml diff --git a/packages/apps/human-app/server/Dockerfile b/packages/apps/human-app/server/Dockerfile deleted file mode 100644 index d39ec93703..0000000000 --- a/packages/apps/human-app/server/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM node:latest -LABEL authors="maciek.nabialek" -WORKDIR /app -COPY package.json yarn.lock ./ -COPY packages/apps/human-app/server ./packages/apps/human-app/server - -WORKDIR /app/packages/apps/human-app/server - -RUN yarn install --frozen-lockfile --ignore-scripts -RUN yarn build -EXPOSE 3000 -CMD ["yarn", "start"] diff --git a/packages/apps/human-app/server/docker-compose.yml b/packages/apps/human-app/server/docker-compose.yml deleted file mode 100644 index dced01d05a..0000000000 --- a/packages/apps/human-app/server/docker-compose.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.8' -services: - app: - build: - context: ../../../.. - dockerfile: packages/apps/human-app/server/Dockerfile - ports: - - "3000:3000" - depends_on: - - redis - environment: - - REDIS_HOST=redis - - REDIS_PORT=6379 - - redis: - image: redis:latest - ports: - - "6379:6379" From ece984376fa341c93883147f36b2322ef1aa6c27 Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Fri, 1 Mar 2024 15:01:23 +0100 Subject: [PATCH 03/10] Changes method naming, adda automapper --- packages/apps/human-app/server/package.json | 2 +- .../apps/human-app/server/src/app.module.ts | 10 +- .../interface/oracle-discovery.interface.ts | 20 --- .../job-discovery/job-discovery.module.ts | 14 -- .../interface/oracle-discovery.interface.ts | 34 +++++ .../oracle-discovery.controller.ts} | 6 +- .../oracle-discovery.mapper.ts} | 3 +- .../oracle-discovery.module.ts | 11 ++ .../oracle-discovery.serivce.ts} | 11 +- .../spec/job-discovery.controller.spec.ts | 0 .../spec/jobi-discovery.service.spec.ts | 0 yarn.lock | 144 ++---------------- 12 files changed, 76 insertions(+), 179 deletions(-) delete mode 100644 packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts delete mode 100644 packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts create mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts rename packages/apps/human-app/server/src/modules/{job-discovery/job-discovery.controller.ts => oracle-discovery/oracle-discovery.controller.ts} (84%) rename packages/apps/human-app/server/src/modules/{job-discovery/job-discovery.mapper.ts => oracle-discovery/oracle-discovery.mapper.ts} (85%) create mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.module.ts rename packages/apps/human-app/server/src/modules/{job-discovery/job-discovery.serivce.ts => oracle-discovery/oracle-discovery.serivce.ts} (78%) rename packages/apps/human-app/server/src/modules/{job-discovery => oracle-discovery}/spec/job-discovery.controller.spec.ts (100%) rename packages/apps/human-app/server/src/modules/{job-discovery => oracle-discovery}/spec/jobi-discovery.service.spec.ts (100%) diff --git a/packages/apps/human-app/server/package.json b/packages/apps/human-app/server/package.json index de90b7cd6f..ad8755a41a 100644 --- a/packages/apps/human-app/server/package.json +++ b/packages/apps/human-app/server/package.json @@ -23,7 +23,7 @@ "@automapper/classes": "^8.8.1", "@automapper/core": "^8.8.1", "@automapper/nestjs": "^8.8.1", - "@human-protocol/sdk": "^2.0.0", + "@human-protocol/sdk": "*", "@nestjs/axios": "^2.0.0", "@nestjs/cache-manager": "^2.2.1", "@nestjs/common": "^10.2.7", diff --git a/packages/apps/human-app/server/src/app.module.ts b/packages/apps/human-app/server/src/app.module.ts index 33390e8450..07d2301f24 100644 --- a/packages/apps/human-app/server/src/app.module.ts +++ b/packages/apps/human-app/server/src/app.module.ts @@ -13,6 +13,8 @@ import { WorkerController } from './modules/user-worker/worker.controller'; import { CommonConfigModule } from './common/config/common-config.module'; import { CacheFactoryConfig } from './common/config/cache-factory.config'; import { CacheModule } from '@nestjs/cache-manager'; +import { OracleDiscoveryController } from './modules/oracle-discovery/oracle-discovery.controller'; +import { OracleDiscoveryModule } from './modules/oracle-discovery/oracle-discovery.module'; @Module({ imports: [ @@ -30,8 +32,14 @@ import { CacheModule } from '@nestjs/cache-manager'; OperatorModule, ReputationOracleModule, CommonConfigModule, + OracleDiscoveryModule, + ], + controllers: [ + AppController, + OperatorController, + WorkerController, + OracleDiscoveryController, ], - controllers: [AppController, OperatorController, WorkerController], providers: [], exports: [HttpModule], }) diff --git a/packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts b/packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts deleted file mode 100644 index 8d51d23c12..0000000000 --- a/packages/apps/human-app/server/src/modules/job-discovery/interface/oracle-discovery.interface.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ChainId, IOperator } from '@human-protocol/sdk'; -export class OracleDiscoveryDto { - chainId: ChainId; - address: string; - role: string; -} -export class OracleDiscoveryCommand { - chainId: ChainId; - address: string; - role: string; -} - -export class OracleDiscoveryData implements IOperator { - address: string; - role?: string; - constructor(address: string, role: string) { - this.address = address; - this.role = role; - } -} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts b/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts deleted file mode 100644 index 3e785b807f..0000000000 --- a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Module } from '@nestjs/common'; -import { ReputationOracleModule } from '../../integrations/reputation-oracle/reputation-oracle.module'; -import { OperatorService } from '../user-operator/operator.service'; -import { OperatorProfile } from '../user-operator/operator.mapper'; -import { JobDiscoveryController } from './job-discovery.controller'; -import { JobDiscoveryService } from './job-discovery.serivce'; -import { JobDiscoveryProfile } from './job-discovery.mapper'; - -@Module({ - controllers: [JobDiscoveryController], - providers: [JobDiscoveryService, JobDiscoveryProfile], - exports: [JobDiscoveryController, JobDiscoveryService], -}) -export class JobDiscoveryModule {} diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts new file mode 100644 index 0000000000..fd25a58ba6 --- /dev/null +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts @@ -0,0 +1,34 @@ +import { ChainId, IOperator } from '@human-protocol/sdk/src'; +import { AutoMap } from '@automapper/classes'; +import { ApiProperty } from '@nestjs/swagger'; +import { IsString } from 'class-validator'; + +export class OracleDiscoveryDto { + @AutoMap() + @ApiProperty({ example: 80001 }) + chainId: ChainId; + @AutoMap() + @ApiProperty({ example: '0x1a23b23432cf23f09f3f' }) + @IsString() + address: string; + @AutoMap() + @ApiProperty({ example: 'Exchange Oracle' }) + role: string; +} +export class OracleDiscoveryCommand { + @AutoMap() + chainId: ChainId; + @AutoMap() + address: string; + @AutoMap() + role: string; +} + +export class OracleDiscoveryData implements IOperator { + address: string; + role?: string; + constructor(address: string, role: string) { + this.address = address; + this.role = role; + } +} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts similarity index 84% rename from packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts rename to packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts index 31e52098a1..c87a2eb914 100644 --- a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.controller.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts @@ -8,7 +8,7 @@ import { import { Mapper } from '@automapper/core'; import { InjectMapper } from '@automapper/nestjs'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; -import { JobDiscoveryService } from './job-discovery.serivce'; +import { OracleDiscoveryService } from './oracle-discovery.serivce'; import { OracleDiscoveryCommand, OracleDiscoveryData, @@ -16,9 +16,9 @@ import { } from './interface/oracle-discovery.interface'; @Controller() -export class JobDiscoveryController { +export class OracleDiscoveryController { constructor( - private readonly service: JobDiscoveryService, + private readonly service: OracleDiscoveryService, @InjectMapper() private readonly mapper: Mapper, ) {} @ApiTags('Oracle-Discovery') diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.mapper.ts similarity index 85% rename from packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts rename to packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.mapper.ts index 213d7ec71a..18d2ce8864 100644 --- a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.mapper.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.mapper.ts @@ -3,12 +3,11 @@ import { AutomapperProfile, InjectMapper } from '@automapper/nestjs'; import { createMap, Mapper } from '@automapper/core'; import { OracleDiscoveryCommand, - OracleDiscoveryData, OracleDiscoveryDto, } from './interface/oracle-discovery.interface'; @Injectable() -export class JobDiscoveryProfile extends AutomapperProfile { +export class OracleDiscoveryProfile extends AutomapperProfile { constructor(@InjectMapper() mapper: Mapper) { super(mapper); } diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.module.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.module.ts new file mode 100644 index 0000000000..758fb807e0 --- /dev/null +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common'; +import { OracleDiscoveryController } from './oracle-discovery.controller'; +import { OracleDiscoveryService } from './oracle-discovery.serivce'; +import { OracleDiscoveryProfile } from './oracle-discovery.mapper'; + +@Module({ + controllers: [OracleDiscoveryController], + providers: [OracleDiscoveryService, OracleDiscoveryProfile], + exports: [OracleDiscoveryService], +}) +export class OracleDiscoveryModule {} diff --git a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts similarity index 78% rename from packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts rename to packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts index be1229d94c..5cf1fe71cd 100644 --- a/packages/apps/human-app/server/src/modules/job-discovery/job-discovery.serivce.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts @@ -1,18 +1,15 @@ import { Inject, Injectable } from '@nestjs/common'; -import { ReputationOracleGateway } from '../../integrations/reputation-oracle/reputation-oracle.gateway'; import { OracleDiscoveryCommand, OracleDiscoveryData, } from './interface/oracle-discovery.interface'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Cache } from 'cache-manager'; -import { IOperator, OperatorUtils } from '@human-protocol/sdk'; - +import { OperatorUtils } from '@human-protocol/sdk/src'; @Injectable() -export class JobDiscoveryService { +export class OracleDiscoveryService { static readonly TTL_1_DAY = 24 * 60 * 60; constructor( - private reputationOracleGateway: ReputationOracleGateway, @Inject(CACHE_MANAGER) private cacheManager: Cache, ) {} @@ -24,7 +21,7 @@ export class JobDiscoveryService { if (cachedData) { return cachedData; } - const data: IOperator[] = + const data: OracleDiscoveryData[] = await this.getOperatorsForOracleDiscovery(command); await this.setOperatorsForAddress(command.address, data); return data; @@ -45,7 +42,7 @@ export class JobDiscoveryService { return this.cacheManager.set( address, operators, - JobDiscoveryService.TTL_1_DAY, + OracleDiscoveryService.TTL_1_DAY, ); }; } diff --git a/packages/apps/human-app/server/src/modules/job-discovery/spec/job-discovery.controller.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/job-discovery.controller.spec.ts similarity index 100% rename from packages/apps/human-app/server/src/modules/job-discovery/spec/job-discovery.controller.spec.ts rename to packages/apps/human-app/server/src/modules/oracle-discovery/spec/job-discovery.controller.spec.ts diff --git a/packages/apps/human-app/server/src/modules/job-discovery/spec/jobi-discovery.service.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/jobi-discovery.service.spec.ts similarity index 100% rename from packages/apps/human-app/server/src/modules/job-discovery/spec/jobi-discovery.service.spec.ts rename to packages/apps/human-app/server/src/modules/oracle-discovery/spec/jobi-discovery.service.spec.ts diff --git a/yarn.lock b/yarn.lock index dccf2fc1fb..5b4fb5390c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2838,24 +2838,6 @@ "@babel/runtime" "^7.17.9" "@hcaptcha/loader" "^1.2.1" -"@human-protocol/sdk@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@human-protocol/sdk/-/sdk-2.0.0.tgz#320eb46cc7045627e42576e22cedf1a05ff49916" - integrity sha512-ZVwZlLIeUnbaeehp79E+vFNJK6ptT1N98GWQ6Pyri88LvDoETWvAmffkMiO+tmDyuuxGebmhB+DpegTtrdHOwQ== - dependencies: - "@human-protocol/core" "*" - aws-sdk "^2.1528.0" - axios "^1.4.0" - crypto "^1.0.1" - graphql "^16.8.1" - graphql-request "^6.1.0" - graphql-tag "^2.12.6" - minio "^7.0.32" - openpgp "^5.10.2" - secp256k1 "^4.0.3" - vitest "^0.30.1" - winston "^3.8.2" - "@humanwhocodes/config-array@^0.11.13": version "0.11.13" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.13.tgz#075dc9684f40a531d9b26b0822153c1e832ee297" @@ -8669,7 +8651,7 @@ async-retry@^1.3.3: dependencies: retry "0.13.1" -async@1.5.2, async@1.x: +async@1.x: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" integrity sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w== @@ -9102,11 +9084,6 @@ blockstore-core@^1.0.2: it-take "^1.0.1" multiformats "^9.4.7" -bluebird@^3.4.6: - version "3.7.2" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - blueimp-md5@^2.10.0: version "2.19.0" resolved "https://registry.yarnpkg.com/blueimp-md5/-/blueimp-md5-2.19.0.tgz#b53feea5498dcb53dc6ec4b823adb84b729c4af0" @@ -9575,24 +9552,6 @@ cache-manager-redis-store@^3.0.1: dependencies: redis "^4.3.1" -cache-manager-redis@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/cache-manager-redis/-/cache-manager-redis-0.6.0.tgz#b364b8e855b287edae1b07780addb9bc9860ebce" - integrity sha512-i7grsVyuIppLyzKAAHM48Eo2YX51+D++Pp1MQiX/9GCBVr3ofayiBpLrz/k/IUpaU9HUZ56P+v5Ee7yJRkfk/w== - dependencies: - cache-manager "^2.2.0" - redis-url "^1.2.1" - sol-redis-pool "^0.3.2" - -cache-manager@^2.2.0: - version "2.11.1" - resolved "https://registry.yarnpkg.com/cache-manager/-/cache-manager-2.11.1.tgz#212e8c3db15288af653b029a1d9fe12f1fd9df61" - integrity sha512-XhUuc9eYwkzpK89iNewFwtvcDYMUsvtwzHeyEOPJna/WsVsXcrzsA1ft2M0QqPNunEzLhNCYPo05tEfG+YuNow== - dependencies: - async "1.5.2" - lodash.clonedeep "4.5.0" - lru-cache "4.0.0" - cache-manager@^5.4.0: version "5.4.0" resolved "https://registry.yarnpkg.com/cache-manager/-/cache-manager-5.4.0.tgz#cec47dbea8e49e0f6970d117be10172b4e621358" @@ -11774,14 +11733,7 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== -ejs@3.1.6: - version "3.1.6" - resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.6.tgz#5bfd0a0689743bb5268b3550cceeebbc1702822a" - integrity sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw== - dependencies: - jake "^10.6.1" - -ejs@^3.1.8: +ejs@3.1.8, ejs@^3.1.8: version "3.1.9" resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.9.tgz#03c9e8777fe12686a9effcef22303ca3d8eeb361" integrity sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ== @@ -13721,11 +13673,6 @@ gauge@^3.0.0: strip-ansi "^6.0.1" wide-align "^1.1.2" -generic-pool@2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-2.2.1.tgz#750ac994eca4e7f87f616e2adff0253f64659ad6" - integrity sha512-nhvlRRwPMl04jnZOEB4Myh8NwNfWpgBbS2IXzdZBdTM7Udvw1/qSCzxd/9P4EanohUzTgNath7v7KQFlOd2W2Q== - generic-pool@3.9.0: version "3.9.0" resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-3.9.0.tgz#36f4a678e963f4fdb8707eab050823abc4e8f5e4" @@ -14089,10 +14036,10 @@ globby@^13.1.2: merge2 "^1.4.1" slash "^4.0.0" -gluegun@5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/gluegun/-/gluegun-5.1.2.tgz#ffa0beda0fb6bbc089a867157b08602beae2c8cf" - integrity sha512-Cwx/8S8Z4YQg07a6AFsaGnnnmd8mN17414NcPS3OoDtZRwxgsvwRNJNg69niD6fDa8oNwslCG0xH7rEpRNNE/g== +gluegun@5.1.2, gluegun@^5.0.0: + version "5.1.6" + resolved "https://registry.yarnpkg.com/gluegun/-/gluegun-5.1.6.tgz#74ec13193913dc610f5c1a4039972c70c96a7bad" + integrity sha512-9zbi4EQWIVvSOftJWquWzr9gLX2kaDgPkNR5dYWbM53eVvCI3iKuxLlnKoHC0v4uPoq+Kr/+F569tjoFbA4DSA== dependencies: apisauce "^2.1.5" app-module-path "^2.2.0" @@ -14100,7 +14047,7 @@ gluegun@5.1.2: colors "1.4.0" cosmiconfig "7.0.1" cross-spawn "7.0.3" - ejs "3.1.6" + ejs "3.1.8" enquirer "2.3.6" execa "5.1.1" fs-jetpack "4.3.1" @@ -16072,7 +16019,7 @@ jackspeak@^2.3.5: optionalDependencies: "@pkgjs/parseargs" "^0.11.0" -jake@^10.6.1, jake@^10.8.5: +jake@^10.8.5: version "10.8.7" resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.7.tgz#63a32821177940c33f356e0ba44ff9d34e1c7d8f" integrity sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w== @@ -17384,7 +17331,7 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== -lodash.clonedeep@4.5.0, lodash.clonedeep@^4.5.0: +lodash.clonedeep@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== @@ -17664,14 +17611,6 @@ lowercase-keys@^2.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== -lru-cache@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.0.tgz#b5cbf01556c16966febe54ceec0fb4dc90df6c28" - integrity sha512-WKhDkjlLwzE8jAQdQlsxLUQTPXLCKX/4cJk6s5AlRtJkDBk0IKH5O51bVDH61K9N4bhbbyvLM6EiOuE8ovApPA== - dependencies: - pseudomap "^1.0.1" - yallist "^2.0.0" - lru-cache@^10.0.2, "lru-cache@^9.1.1 || ^10.0.0": version "10.1.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.1.0.tgz#2098d41c2dc56500e6c88584aa656c84de7d0484" @@ -18703,7 +18642,7 @@ node-fetch@2.7.0, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node dependencies: whatwg-url "^5.0.0" -node-forge@^1.3.1: +node-forge@^1.0.0, node-forge@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== @@ -20218,11 +20157,6 @@ proxy-from-env@^1.1.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -pseudomap@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== - psl@^1.1.28, psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" @@ -20299,7 +20233,7 @@ pvutils@^1.1.3: resolved "https://registry.yarnpkg.com/pvutils/-/pvutils-1.1.3.tgz#f35fc1d27e7cd3dfbd39c0826d173e806a03f5a3" integrity sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ== -qrcode@1.5.3, qrcode@^1.5.1: +qrcode@1.5.3, qrcode@^1.5.0, qrcode@^1.5.1: version "1.5.3" resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.5.3.tgz#03afa80912c0dccf12bc93f615a535aad1066170" integrity sha512-puyri6ApkEHYiVl4CFzo1tDkAZ+ATcnbJrJ6RiBM1Fhctdn/ix9MTE3hRph33omisEbC/2fcfemsseiKgBPKZg== @@ -20935,14 +20869,7 @@ redis-parser@^3.0.0: dependencies: redis-errors "^1.0.0" -redis-url@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/redis-url/-/redis-url-1.2.1.tgz#18670095a38e989d379359dd4c6e4abff85e2eb1" - integrity sha512-KL+/sxJXNecWSpRZj4MhRFXkfzG9Mip62x5BDNLIaN87JtdyWHHbm09qGiSfMr5yjhKeHLju79hgSCoi1WcYRg== - dependencies: - redis ">= 0.0.1" - -"redis@>= 0.0.1", "redis@>= 2.6.2", redis@^4.3.1: +redis@^4.3.1: version "4.6.13" resolved "https://registry.yarnpkg.com/redis/-/redis-4.6.13.tgz#e247267c5f3ba35ab8277b57343d3a56acb2f0a6" integrity sha512-MHgkS4B+sPjCXpf+HfdetBwbRz6vCtsceTmw1pHNYJAsYxrfpOP6dz+piJWGos8wqG7qb3vj/Rrc5qOlmInUuA== @@ -21668,38 +21595,7 @@ secp256k1@^4.0.1, secp256k1@^4.0.3: node-addon-api "^2.0.0" node-gyp-build "^4.2.0" -"semver@2 || 3 || 4 || 5", semver@^5.5.0: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - -semver@7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== - dependencies: - lru-cache "^6.0.0" - -semver@7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.4.0.tgz#8481c92feffc531ab1e012a8ffc15bdd3a0f4318" - integrity sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw== - dependencies: - lru-cache "^6.0.0" - -semver@7.5.4: - version "7.5.4" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" - integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== - dependencies: - lru-cache "^6.0.0" - -semver@^6.0.0, semver@^6.3.0, semver@^6.3.1: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4: +"semver@2 || 3 || 4 || 5", semver@7.3.5, semver@7.4.0, semver@7.5.4, semver@^5.5.0, semver@^6.0.0, semver@^6.3.0, semver@^6.3.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4: version "7.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== @@ -22117,15 +22013,6 @@ snapdragon@^0.8.1: source-map-resolve "^0.5.0" use "^3.1.0" -sol-redis-pool@^0.3.2: - version "0.3.3" - resolved "https://registry.yarnpkg.com/sol-redis-pool/-/sol-redis-pool-0.3.3.tgz#a7111d6f8942413ba0ad4733566167052db74a6b" - integrity sha512-sDXjqFOPVu/e3k0G0l7ECJ0V4Hm51ECyZYOPah1uYigJve3IUenj/y9tAw2o9mr4ORLbcMRIaw4ovn+RgXMnZA== - dependencies: - bluebird "^3.4.6" - generic-pool "2.2.1" - redis ">= 2.6.2" - solc@0.7.3: version "0.7.3" resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a" @@ -25190,11 +25077,6 @@ yallist@4.0.0, yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yallist@^2.0.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A== - yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" From b4a5b477f940ac22391d11ce900badf123f9e85b Mon Sep 17 00:00:00 2001 From: portuu3 <61605646+portuu3@users.noreply.github.com> Date: Tue, 20 Feb 2024 16:34:45 +0100 Subject: [PATCH 04/10] fix ts sdk docs (#1610) --- docs/sdk/SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sdk/SUMMARY.md b/docs/sdk/SUMMARY.md index a7dc430337..9e8caeae52 100644 --- a/docs/sdk/SUMMARY.md +++ b/docs/sdk/SUMMARY.md @@ -13,7 +13,7 @@ - [Staking](typescript/modules/staking.md) - [StakingClient](typescript/classes/staking.StakingClient.md) - [Operator](typescript/modules/operator.md) - - [OperatorUtils](typescript/classes/staoperatorking.OperatorUtils.md) + - [OperatorUtils](typescript/classes/operator.OperatorUtils.md) - [Storage](typescript/modules/storage.md) - [StorageClient](typescript/classes/storage.StorageClient.md) - [Statistics](typescript/modules/statistics.md) From 90f40094c3eeb24b703ecbf1a1fea240e19b7f9c Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Mon, 4 Mar 2024 15:09:14 +0100 Subject: [PATCH 05/10] Adds minor reworks and logging --- .../interface/oracle-discovery.interface.ts | 9 +++++--- .../oracle-discovery.controller.ts | 9 ++++++++ .../oracle-discovery.serivce.ts | 23 +++++++++---------- packages/apps/human-app/server/tsconfig.json | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts index fd25a58ba6..1d3c10cf51 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts @@ -1,7 +1,6 @@ -import { ChainId, IOperator } from '@human-protocol/sdk/src'; +import { ChainId, IOperator } from '@human-protocol/sdk'; import { AutoMap } from '@automapper/classes'; import { ApiProperty } from '@nestjs/swagger'; -import { IsString } from 'class-validator'; export class OracleDiscoveryDto { @AutoMap() @@ -9,11 +8,15 @@ export class OracleDiscoveryDto { chainId: ChainId; @AutoMap() @ApiProperty({ example: '0x1a23b23432cf23f09f3f' }) - @IsString() address: string; @AutoMap() @ApiProperty({ example: 'Exchange Oracle' }) role: string; + constructor(chainId: ChainId, address: string, role: string) { + this.chainId = chainId; + this.address = address; + this.role = role; + } } export class OracleDiscoveryCommand { @AutoMap() diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts index c87a2eb914..8085078216 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts @@ -2,6 +2,7 @@ import { Body, Controller, Get, + Logger, UsePipes, ValidationPipe, } from '@nestjs/common'; @@ -17,6 +18,7 @@ import { @Controller() export class OracleDiscoveryController { + logger = new Logger(OracleDiscoveryController.name); constructor( private readonly service: OracleDiscoveryService, @InjectMapper() private readonly mapper: Mapper, @@ -28,6 +30,13 @@ export class OracleDiscoveryController { public signupOperator( @Body() oracleDiscoveryDto: OracleDiscoveryDto, ): Promise { + this.logger.log( + `Oracle Discovery request: { + chainId: ${oracleDiscoveryDto.chainId}, + address: ${oracleDiscoveryDto.address}, + role: ${oracleDiscoveryDto.role} + }`, + ); const oracleDiscoveryCommand = this.mapper.map( oracleDiscoveryDto, OracleDiscoveryDto, diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts index 5cf1fe71cd..4732a294fa 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts @@ -1,29 +1,28 @@ -import { Inject, Injectable } from '@nestjs/common'; +import { Inject, Injectable, Logger } from '@nestjs/common'; import { OracleDiscoveryCommand, OracleDiscoveryData, } from './interface/oracle-discovery.interface'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Cache } from 'cache-manager'; -import { OperatorUtils } from '@human-protocol/sdk/src'; +import { OperatorUtils } from '@human-protocol/sdk'; @Injectable() export class OracleDiscoveryService { static readonly TTL_1_DAY = 24 * 60 * 60; - constructor( - @Inject(CACHE_MANAGER) private cacheManager: Cache, - ) {} + logger = new Logger(OracleDiscoveryService.name); + constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {} async processOracleDiscovery( command: OracleDiscoveryCommand, ): Promise { - const cachedData: OracleDiscoveryData[] | undefined = - await this.cacheManager.get(command.address); - if (cachedData) { - return cachedData; + let data: OracleDiscoveryData[] | undefined = await this.cacheManager.get( + command.address, + ); + if (!data) { + data = await this.getOperatorsForOracleDiscovery(command); + await this.setOperatorsForAddress(command.address, data); } - const data: OracleDiscoveryData[] = - await this.getOperatorsForOracleDiscovery(command); - await this.setOperatorsForAddress(command.address, data); + this.logger.log(`Returning data: ${JSON.stringify(data)}`); return data; } getOperatorsForOracleDiscovery = ( diff --git a/packages/apps/human-app/server/tsconfig.json b/packages/apps/human-app/server/tsconfig.json index b23fdd9e74..21da75fe79 100644 --- a/packages/apps/human-app/server/tsconfig.json +++ b/packages/apps/human-app/server/tsconfig.json @@ -7,7 +7,7 @@ "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "allowJs": true, - "target": "es2017", + "target": "es2020", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", From 929a08d55f89386aafe69cb06910256ffb861425 Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Mon, 4 Mar 2024 23:10:25 +0100 Subject: [PATCH 06/10] Adds testing --- .../oracle-discovery.controller.ts | 2 +- .../spec/job-discovery.controller.spec.ts | 0 .../spec/oracle-discovery.controller.spec.ts | 65 ++++++++++++++ .../spec/oracle-discovery.service.spec.ts | 90 +++++++++++++++++++ .../test/fixtures/oracle-discovery.fixture.ts | 13 +++ 5 files changed, 169 insertions(+), 1 deletion(-) delete mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/spec/job-discovery.controller.spec.ts create mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts create mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts create mode 100644 packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts index 8085078216..0bcde7814f 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts @@ -27,7 +27,7 @@ export class OracleDiscoveryController { @Get('/oracles') @ApiOperation({ summary: 'Operator signup' }) @UsePipes(new ValidationPipe()) - public signupOperator( + public oracleDiscovery( @Body() oracleDiscoveryDto: OracleDiscoveryDto, ): Promise { this.logger.log( diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/job-discovery.controller.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/job-discovery.controller.spec.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts new file mode 100644 index 0000000000..59914f06ac --- /dev/null +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts @@ -0,0 +1,65 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AutomapperModule } from '@automapper/nestjs'; +import { classes } from '@automapper/classes'; +import { OracleDiscoveryController } from '../oracle-discovery.controller'; +import { OracleDiscoveryService } from '../oracle-discovery.serivce'; +import { oracleDiscoveryServiceMock } from './oracle-discovery.service.mock'; +import { OracleDiscoveryProfile } from '../oracle-discovery.mapper'; +import { + OracleDiscoveryCommand, + OracleDiscoveryData, + OracleDiscoveryDto, +} from '../interface/oracle-discovery.interface'; +import { ChainId } from '@human-protocol/sdk'; +import { generateOracleDiscoveryResponseBody } from '../../../../test/fixtures/oracle-discovery.fixture'; + +describe('OracleDiscoveryController', () => { + let controller: OracleDiscoveryController; + let service: OracleDiscoveryService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [OracleDiscoveryController], + imports: [ + AutomapperModule.forRoot({ + strategyInitializer: classes(), + }), + ], + providers: [OracleDiscoveryService, OracleDiscoveryProfile], + }) + .overrideProvider(OracleDiscoveryService) + .useValue(oracleDiscoveryServiceMock) + .compile(); + + controller = module.get( + OracleDiscoveryController, + ); + service = module.get(OracleDiscoveryService); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); + + describe('oracle discovery', () => { + it('oracle discovery should be called with input in OracleDiscoveryDto format and return OracleDiscoveryData', async () => { + const dto: OracleDiscoveryDto = { + chainId: 80001, + address: '0x4708354213453af0cdC33eb75d94fBC00045841E', + role: 'Exchange Oracle', + }; + const result: OracleDiscoveryData[] = + await controller.oracleDiscovery(dto); + const expectedCommand = { + chainId: ChainId.POLYGON_MUMBAI, + address: dto.address, + role: 'Exchange Oracle', + } as OracleDiscoveryCommand; + expect(service.processOracleDiscovery).toHaveBeenCalledWith( + expectedCommand, + ); + const expectedResponse = generateOracleDiscoveryResponseBody(); + expect(result).toEqual(expectedResponse); + }); + }); +}); diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts new file mode 100644 index 0000000000..077925842b --- /dev/null +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts @@ -0,0 +1,90 @@ +import { Test } from '@nestjs/testing'; +import { Cache } from 'cache-manager'; +import { OracleDiscoveryService } from '../oracle-discovery.serivce'; +import { CACHE_MANAGER } from '@nestjs/cache-manager'; +import { OperatorUtils } from '@human-protocol/sdk'; +import { + OracleDiscoveryCommand, + OracleDiscoveryData, +} from '../interface/oracle-discovery.interface'; + +jest.mock('@human-protocol/sdk', () => ({ + OperatorUtils: { + getReputationNetworkOperators: jest.fn(), + }, +})); + +describe('OracleDiscoveryService', () => { + let oracleDiscoveryService: OracleDiscoveryService; + let cacheManager: Cache; + + beforeEach(async () => { + const moduleRef = await Test.createTestingModule({ + providers: [ + OracleDiscoveryService, + { + provide: CACHE_MANAGER, + useValue: { + get: jest.fn(), + set: jest.fn(), + }, + }, + ], + }).compile(); + + oracleDiscoveryService = moduleRef.get( + OracleDiscoveryService, + ); + cacheManager = moduleRef.get(CACHE_MANAGER); + }); + + it('should return cached data if available', async () => { + const mockData: OracleDiscoveryData[] = [ + { address: 'mockAddress1', role: 'validator' }, + { address: 'mockAddress2', role: 'validator' }, + ]; + const command: OracleDiscoveryCommand = { + address: 'mockAddress', + chainId: 80001, + role: 'validator', + }; + jest.spyOn(cacheManager, 'get').mockResolvedValue(mockData); + + const result = await oracleDiscoveryService.processOracleDiscovery(command); + + expect(result).toEqual(mockData); + expect(cacheManager.get).toHaveBeenCalledWith(command.address); + expect(OperatorUtils.getReputationNetworkOperators).not.toHaveBeenCalled(); + }); + + it('should fetch and cache data if not already cached', async () => { + const mockData: OracleDiscoveryData[] = [ + { address: 'mockAddress1', role: 'validator' }, + { address: 'mockAddress2', role: 'validator' }, + ]; + const command: OracleDiscoveryCommand = { + address: 'mockAddress', + chainId: 80001, + role: 'validator', + }; + jest.spyOn(cacheManager, 'get').mockResolvedValue(undefined); + jest + .spyOn(OperatorUtils, 'getReputationNetworkOperators') + .mockResolvedValue(mockData); + + const result = await oracleDiscoveryService.processOracleDiscovery(command); + + expect(result).toEqual(mockData); + expect(cacheManager.get).toHaveBeenCalledWith(command.address); + expect(cacheManager.set).toHaveBeenCalledWith( + command.address, + mockData, + OracleDiscoveryService.TTL_1_DAY, + ); + expect(OperatorUtils.getReputationNetworkOperators).toHaveBeenCalledWith( + command.chainId, + command.address, + command.role, + ); + }); +}); diff --git a/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts b/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts new file mode 100644 index 0000000000..575cb68b06 --- /dev/null +++ b/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts @@ -0,0 +1,13 @@ +import { OracleDiscoveryData } from '../../src/modules/oracle-discovery/interface/oracle-discovery.interface'; + +export function generateOracleDiscoveryResponseBody() { + const response1: OracleDiscoveryData = { + address: '0xd06eac24a0c47c776Ce6826A93162c4AfC029047', + role: 'role1', + }; + const response2: OracleDiscoveryData = { + address: '0xd10c3402155c058D78e4D5fB5f50E125F06eb39d', + role: 'role2', + }; + return [response1, response2]; +} From c649fbf1982f6c31fcd026d57732f346126a2909 Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Mon, 4 Mar 2024 23:23:07 +0100 Subject: [PATCH 07/10] Adds minor review fixes --- packages/apps/human-app/server/.env.example | 1 + .../src/common/config/environment-config.service.ts | 7 +++++++ .../interface/oracle-discovery.interface.ts | 2 +- .../modules/oracle-discovery/oracle-discovery.serivce.ts | 9 ++++++--- .../spec/oracle-discovery.service.mock.ts | 7 +++++++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts diff --git a/packages/apps/human-app/server/.env.example b/packages/apps/human-app/server/.env.example index 9a1f74e42d..197e36a744 100644 --- a/packages/apps/human-app/server/.env.example +++ b/packages/apps/human-app/server/.env.example @@ -5,3 +5,4 @@ REDIS_PORT= REDIS_HOST= E2E_TESTING_EMAIL_ADDRESS= E2E_TESTING_PASSWORD= +CACHE_TTL_ORACLE_DISCOVERY= \ No newline at end of file diff --git a/packages/apps/human-app/server/src/common/config/environment-config.service.ts b/packages/apps/human-app/server/src/common/config/environment-config.service.ts index 0cea45491d..293b8e48cb 100644 --- a/packages/apps/human-app/server/src/common/config/environment-config.service.ts +++ b/packages/apps/human-app/server/src/common/config/environment-config.service.ts @@ -20,6 +20,13 @@ export class EnvironmentConfigService { get cacheHost(): string { return this.configService.get('REDIS_HOST', 'localhost'); } + + get cacheTtlOracleDiscovery(): number { + return this.configService.get( + 'CACHE_TTL_ORACLE_DISCOVERY', + 24 * 60 * 60, + ); + } } export const envValidator = Joi.object({ diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts index 1d3c10cf51..2f25f1f4bd 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts @@ -29,7 +29,7 @@ export class OracleDiscoveryCommand { export class OracleDiscoveryData implements IOperator { address: string; - role?: string; + role: string; constructor(address: string, role: string) { this.address = address; this.role = role; diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts index 4732a294fa..186d952e29 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts @@ -6,11 +6,14 @@ import { import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Cache } from 'cache-manager'; import { OperatorUtils } from '@human-protocol/sdk'; +import { EnvironmentConfigService } from '../../common/config/environment-config.service'; @Injectable() export class OracleDiscoveryService { - static readonly TTL_1_DAY = 24 * 60 * 60; logger = new Logger(OracleDiscoveryService.name); - constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {} + constructor( + @Inject(CACHE_MANAGER) private cacheManager: Cache, + private configService: EnvironmentConfigService, + ) {} async processOracleDiscovery( command: OracleDiscoveryCommand, @@ -41,7 +44,7 @@ export class OracleDiscoveryService { return this.cacheManager.set( address, operators, - OracleDiscoveryService.TTL_1_DAY, + this.configService.cacheTtlOracleDiscovery, ); }; } diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts new file mode 100644 index 0000000000..2a27a2c132 --- /dev/null +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts @@ -0,0 +1,7 @@ +import { generateOracleDiscoveryResponseBody } from '../../../../test/fixtures/oracle-discovery.fixture'; + +export const oracleDiscoveryServiceMock = { + processOracleDiscovery: jest + .fn() + .mockResolvedValue(generateOracleDiscoveryResponseBody()), +}; From 6013b517c76b583eb0715b44d98d2dffd3616611 Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Tue, 5 Mar 2024 14:08:04 +0100 Subject: [PATCH 08/10] Adds minor review fixes --- .../interface/oracle-discovery.interface.ts | 4 +-- .../oracle-discovery.controller.ts | 4 +-- .../oracle-discovery.serivce.ts | 24 ++++++++--------- .../spec/oracle-discovery.controller.spec.ts | 4 +-- .../spec/oracle-discovery.service.spec.ts | 27 +++++++++++++++---- .../test/fixtures/oracle-discovery.fixture.ts | 6 ++--- 6 files changed, 43 insertions(+), 26 deletions(-) diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts index 2f25f1f4bd..3dd9549023 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/interface/oracle-discovery.interface.ts @@ -27,9 +27,9 @@ export class OracleDiscoveryCommand { role: string; } -export class OracleDiscoveryData implements IOperator { +export class OracleDiscoveryResponse implements IOperator { address: string; - role: string; + role?: string; constructor(address: string, role: string) { this.address = address; this.role = role; diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts index 0bcde7814f..fca2c6eaf9 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts @@ -12,7 +12,7 @@ import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { OracleDiscoveryService } from './oracle-discovery.serivce'; import { OracleDiscoveryCommand, - OracleDiscoveryData, + OracleDiscoveryResponse, OracleDiscoveryDto, } from './interface/oracle-discovery.interface'; @@ -29,7 +29,7 @@ export class OracleDiscoveryController { @UsePipes(new ValidationPipe()) public oracleDiscovery( @Body() oracleDiscoveryDto: OracleDiscoveryDto, - ): Promise { + ): Promise { this.logger.log( `Oracle Discovery request: { chainId: ${oracleDiscoveryDto.chainId}, diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts index 186d952e29..acf57c3b99 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts @@ -1,7 +1,7 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; import { OracleDiscoveryCommand, - OracleDiscoveryData, + OracleDiscoveryResponse, } from './interface/oracle-discovery.interface'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Cache } from 'cache-manager'; @@ -17,10 +17,9 @@ export class OracleDiscoveryService { async processOracleDiscovery( command: OracleDiscoveryCommand, - ): Promise { - let data: OracleDiscoveryData[] | undefined = await this.cacheManager.get( - command.address, - ); + ): Promise { + let data: OracleDiscoveryResponse[] | undefined = + await this.cacheManager.get(command.address); if (!data) { data = await this.getOperatorsForOracleDiscovery(command); await this.setOperatorsForAddress(command.address, data); @@ -28,23 +27,24 @@ export class OracleDiscoveryService { this.logger.log(`Returning data: ${JSON.stringify(data)}`); return data; } - getOperatorsForOracleDiscovery = ( + + async getOperatorsForOracleDiscovery( cmd: OracleDiscoveryCommand, - ): Promise => { + ): Promise { return OperatorUtils.getReputationNetworkOperators( cmd.chainId, cmd.address, cmd.role, ); - }; - setOperatorsForAddress = ( + } + async setOperatorsForAddress( address: string, - operators: OracleDiscoveryData[], - ): Promise => { + operators: OracleDiscoveryResponse[], + ): Promise { return this.cacheManager.set( address, operators, this.configService.cacheTtlOracleDiscovery, ); - }; + } } diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts index 59914f06ac..2f965594e5 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts @@ -7,7 +7,7 @@ import { oracleDiscoveryServiceMock } from './oracle-discovery.service.mock'; import { OracleDiscoveryProfile } from '../oracle-discovery.mapper'; import { OracleDiscoveryCommand, - OracleDiscoveryData, + OracleDiscoveryResponse, OracleDiscoveryDto, } from '../interface/oracle-discovery.interface'; import { ChainId } from '@human-protocol/sdk'; @@ -48,7 +48,7 @@ describe('OracleDiscoveryController', () => { address: '0x4708354213453af0cdC33eb75d94fBC00045841E', role: 'Exchange Oracle', }; - const result: OracleDiscoveryData[] = + const result: OracleDiscoveryResponse[] = await controller.oracleDiscovery(dto); const expectedCommand = { chainId: ChainId.POLYGON_MUMBAI, diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts index 077925842b..56a965ae04 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.spec.ts @@ -5,8 +5,11 @@ import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { OperatorUtils } from '@human-protocol/sdk'; import { OracleDiscoveryCommand, - OracleDiscoveryData, + OracleDiscoveryResponse, } from '../interface/oracle-discovery.interface'; +import { EnvironmentConfigService, envValidator } from '../../../common/config/environment-config.service'; +import { CommonConfigModule } from '../../../common/config/common-config.module'; +import { ConfigModule } from '@nestjs/config'; jest.mock('@human-protocol/sdk', () => ({ OperatorUtils: { @@ -17,9 +20,18 @@ jest.mock('@human-protocol/sdk', () => ({ describe('OracleDiscoveryService', () => { let oracleDiscoveryService: OracleDiscoveryService; let cacheManager: Cache; + let configService: EnvironmentConfigService; beforeEach(async () => { const moduleRef = await Test.createTestingModule({ + imports: [ + CommonConfigModule, + ConfigModule.forRoot({ + envFilePath: '.env', + isGlobal: true, + validationSchema: envValidator, + }), + ], providers: [ OracleDiscoveryService, { @@ -31,15 +43,20 @@ describe('OracleDiscoveryService', () => { }, ], }).compile(); - + configService = moduleRef.get( + EnvironmentConfigService, + ); oracleDiscoveryService = moduleRef.get( OracleDiscoveryService, ); cacheManager = moduleRef.get(CACHE_MANAGER); }); + it('should be defined', () => { + expect(oracleDiscoveryService).toBeDefined(); + }); it('should return cached data if available', async () => { - const mockData: OracleDiscoveryData[] = [ + const mockData: OracleDiscoveryResponse[] = [ { address: 'mockAddress1', role: 'validator' }, { address: 'mockAddress2', role: 'validator' }, ]; @@ -58,7 +75,7 @@ describe('OracleDiscoveryService', () => { }); it('should fetch and cache data if not already cached', async () => { - const mockData: OracleDiscoveryData[] = [ + const mockData: OracleDiscoveryResponse[] = [ { address: 'mockAddress1', role: 'validator' }, { address: 'mockAddress2', role: 'validator' }, ]; @@ -79,7 +96,7 @@ describe('OracleDiscoveryService', () => { expect(cacheManager.set).toHaveBeenCalledWith( command.address, mockData, - OracleDiscoveryService.TTL_1_DAY, + configService.cacheTtlOracleDiscovery, ); expect(OperatorUtils.getReputationNetworkOperators).toHaveBeenCalledWith( command.chainId, diff --git a/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts b/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts index 575cb68b06..14df41efc6 100644 --- a/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts +++ b/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts @@ -1,11 +1,11 @@ -import { OracleDiscoveryData } from '../../src/modules/oracle-discovery/interface/oracle-discovery.interface'; +import { OracleDiscoveryResponse } from '../../src/modules/oracle-discovery/interface/oracle-discovery.interface'; export function generateOracleDiscoveryResponseBody() { - const response1: OracleDiscoveryData = { + const response1: OracleDiscoveryResponse = { address: '0xd06eac24a0c47c776Ce6826A93162c4AfC029047', role: 'role1', }; - const response2: OracleDiscoveryData = { + const response2: OracleDiscoveryResponse = { address: '0xd10c3402155c058D78e4D5fB5f50E125F06eb39d', role: 'role2', }; From c3f5d013bdb257d31faabcd39ce50171a7c2c5b5 Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Tue, 5 Mar 2024 14:12:30 +0100 Subject: [PATCH 09/10] Minor dependencies changes --- packages/apps/human-app/server/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/apps/human-app/server/package.json b/packages/apps/human-app/server/package.json index ad8755a41a..3617272b71 100644 --- a/packages/apps/human-app/server/package.json +++ b/packages/apps/human-app/server/package.json @@ -42,7 +42,9 @@ "devDependencies": { "@nestjs/cache-manager": "^2.2.1", "@nestjs/cli": "^9.4.3", + "@nestjs/schematics": "^9.2.0", "@nestjs/testing": "^9.4.3", + "@types/express": "^4.17.13", "@types/jest": "29.5.1", "@types/node": "20.10.4", "@types/supertest": "^2.0.15", @@ -56,6 +58,7 @@ "jest": "29.5.0", "nock": "^13.5.1", "prettier": "^3.1.1", + "source-map-support": "^0.5.20", "supertest": "^6.1.3", "ts-jest": "29.1.1", "ts-loader": "^9.2.3", From dede81c9a6f18c912e0b90cfec0f92d191a74ae7 Mon Sep 17 00:00:00 2001 From: "maciek.nabialek" Date: Wed, 6 Mar 2024 10:12:11 +0100 Subject: [PATCH 10/10] Fixes after review --- .../oracle-discovery/oracle-discovery.controller.ts | 13 ++----------- .../oracle-discovery/oracle-discovery.serivce.ts | 4 +--- .../spec/jobi-discovery.service.spec.ts | 0 .../spec/oracle-discovery.controller.spec.ts | 2 +- .../spec}/oracle-discovery.fixture.ts | 2 +- .../spec/oracle-discovery.service.mock.ts | 2 +- 6 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 packages/apps/human-app/server/src/modules/oracle-discovery/spec/jobi-discovery.service.spec.ts rename packages/apps/human-app/server/{test/fixtures => src/modules/oracle-discovery/spec}/oracle-discovery.fixture.ts (75%) diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts index fca2c6eaf9..c682105af5 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.controller.ts @@ -2,7 +2,6 @@ import { Body, Controller, Get, - Logger, UsePipes, ValidationPipe, } from '@nestjs/common'; @@ -18,25 +17,17 @@ import { @Controller() export class OracleDiscoveryController { - logger = new Logger(OracleDiscoveryController.name); constructor( private readonly service: OracleDiscoveryService, @InjectMapper() private readonly mapper: Mapper, ) {} @ApiTags('Oracle-Discovery') - @Get('/oracles') - @ApiOperation({ summary: 'Operator signup' }) + @Get('/discovery/oracles') + @ApiOperation({ summary: 'Oracles discovery' }) @UsePipes(new ValidationPipe()) public oracleDiscovery( @Body() oracleDiscoveryDto: OracleDiscoveryDto, ): Promise { - this.logger.log( - `Oracle Discovery request: { - chainId: ${oracleDiscoveryDto.chainId}, - address: ${oracleDiscoveryDto.address}, - role: ${oracleDiscoveryDto.role} - }`, - ); const oracleDiscoveryCommand = this.mapper.map( oracleDiscoveryDto, OracleDiscoveryDto, diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts index acf57c3b99..c593a921e8 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.serivce.ts @@ -1,4 +1,4 @@ -import { Inject, Injectable, Logger } from '@nestjs/common'; +import { Inject, Injectable } from '@nestjs/common'; import { OracleDiscoveryCommand, OracleDiscoveryResponse, @@ -9,7 +9,6 @@ import { OperatorUtils } from '@human-protocol/sdk'; import { EnvironmentConfigService } from '../../common/config/environment-config.service'; @Injectable() export class OracleDiscoveryService { - logger = new Logger(OracleDiscoveryService.name); constructor( @Inject(CACHE_MANAGER) private cacheManager: Cache, private configService: EnvironmentConfigService, @@ -24,7 +23,6 @@ export class OracleDiscoveryService { data = await this.getOperatorsForOracleDiscovery(command); await this.setOperatorsForAddress(command.address, data); } - this.logger.log(`Returning data: ${JSON.stringify(data)}`); return data; } diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/jobi-discovery.service.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/jobi-discovery.service.spec.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts index 2f965594e5..0e86b9276e 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.controller.spec.ts @@ -11,7 +11,7 @@ import { OracleDiscoveryDto, } from '../interface/oracle-discovery.interface'; import { ChainId } from '@human-protocol/sdk'; -import { generateOracleDiscoveryResponseBody } from '../../../../test/fixtures/oracle-discovery.fixture'; +import { generateOracleDiscoveryResponseBody } from './oracle-discovery.fixture'; describe('OracleDiscoveryController', () => { let controller: OracleDiscoveryController; diff --git a/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.fixture.ts similarity index 75% rename from packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts rename to packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.fixture.ts index 14df41efc6..d3483e9b1e 100644 --- a/packages/apps/human-app/server/test/fixtures/oracle-discovery.fixture.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.fixture.ts @@ -1,4 +1,4 @@ -import { OracleDiscoveryResponse } from '../../src/modules/oracle-discovery/interface/oracle-discovery.interface'; +import { OracleDiscoveryResponse } from '../interface/oracle-discovery.interface'; export function generateOracleDiscoveryResponseBody() { const response1: OracleDiscoveryResponse = { diff --git a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts index 2a27a2c132..b9d98d5256 100644 --- a/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts +++ b/packages/apps/human-app/server/src/modules/oracle-discovery/spec/oracle-discovery.service.mock.ts @@ -1,4 +1,4 @@ -import { generateOracleDiscoveryResponseBody } from '../../../../test/fixtures/oracle-discovery.fixture'; +import { generateOracleDiscoveryResponseBody } from './oracle-discovery.fixture'; export const oracleDiscoveryServiceMock = { processOracleDiscovery: jest