diff --git a/apps/aggregator/deployment/app-chart/templates/aggregator-configmap.yaml b/apps/aggregator/deployment/app-chart/templates/aggregator-configmap.yaml index 414e0ee..8324157 100644 --- a/apps/aggregator/deployment/app-chart/templates/aggregator-configmap.yaml +++ b/apps/aggregator/deployment/app-chart/templates/aggregator-configmap.yaml @@ -7,3 +7,5 @@ data: NEST_APP_TYPE: aggregator AGGREGATOR_POLLING_SCHEDULE: "{{ .Values.environment.aggregator_polling_schedule }}" LOG_LEVELS: "log,warn,error" + SODAKI_API_BASE_URL: "{{ .Values.environment.sodaki_api_base_url }}" + COINGECKO_API_BASE_URL: "{{ .Values.environment.coingecko_api_base_url }}" diff --git a/apps/aggregator/deployment/app-chart/values.yaml b/apps/aggregator/deployment/app-chart/values.yaml index 4ce6775..c3f4d65 100644 --- a/apps/aggregator/deployment/app-chart/values.yaml +++ b/apps/aggregator/deployment/app-chart/values.yaml @@ -87,3 +87,5 @@ version: environment: aggregator_polling_schedule: "0 * * * *" + sodaki_api_base_url: "https://sodaki.com/api" + coingecko_api_base_url: "https://api.coingecko.com/api/v3" diff --git a/apps/aggregator/src/aggregator.module.ts b/apps/aggregator/src/aggregator.module.ts index 1aa599f..342a26a 100644 --- a/apps/aggregator/src/aggregator.module.ts +++ b/apps/aggregator/src/aggregator.module.ts @@ -1,4 +1,5 @@ import { ClassSerializerInterceptor, Module } from '@nestjs/common'; +import { APP_INTERCEPTOR } from '@nestjs/core'; import { ConfigModule } from '@nestjs/config'; import { TypeOrmModule } from '@nestjs/typeorm'; import { ScheduleModule } from '@nestjs/schedule'; @@ -13,16 +14,15 @@ import { RedisModule } from '@dao-stats/redis'; import { TransactionModule } from '@dao-stats/transaction'; import { HttpCacheModule } from '@dao-stats/cache'; import { + CoinPriceHistoryModule, + ContractModule, DaoStatsModule, DaoStatsHistoryModule, DaoModule, } from '@dao-stats/common'; -import { AggregatorService } from './aggregator.service'; -import { APP_INTERCEPTOR } from '@nestjs/core'; import { ReceiptModule } from '@dao-stats/receipt'; -import { CoinPriceHistoryModule } from '@dao-stats/common/coin-price-history.module'; -import { ContractModule } from 'apps/api/src/contract/contract.module'; -import { ExchangeModule } from 'libs/exchange/src/exchange.module'; +import { ExchangeModule } from '@dao-stats/exchange'; +import { AggregatorService } from './aggregator.service'; @Module({ imports: [ diff --git a/apps/aggregator/src/aggregator.service.ts b/apps/aggregator/src/aggregator.service.ts index 7153ab4..386a209 100644 --- a/apps/aggregator/src/aggregator.service.ts +++ b/apps/aggregator/src/aggregator.service.ts @@ -1,25 +1,25 @@ import moment from 'moment'; +import { CronJob } from 'cron'; import { ConfigService } from '@nestjs/config'; import { LazyModuleLoader } from '@nestjs/core'; import { Injectable, Logger } from '@nestjs/common'; import { SchedulerRegistry } from '@nestjs/schedule'; -import { CronJob } from 'cron'; import { Aggregator, + AGGREGATOR_POLLING_CRON_JOB, + CoinPriceHistoryService, + ContractService, + CurrencyType, DaoService, - DaoStatsService, DaoStatsHistoryService, + DaoStatsService, millisToNanos, nanosToMillis, - AGGREGATOR_POLLING_CRON_JOB, } from '@dao-stats/common'; import { TransactionService } from '@dao-stats/transaction'; import { CacheService } from '@dao-stats/cache'; import { ReceiptActionService } from '@dao-stats/receipt'; -import { ContractService } from 'apps/api/src/contract/contract.service'; -import { CurrencyType } from '@dao-stats/common/types/currency-type'; import { CoinGeckoService, SodakiService } from '@dao-stats/exchange'; -import { CoinPriceHistoryService } from '@dao-stats/common/coin-price-history.service'; @Injectable() export class AggregatorService { @@ -165,7 +165,7 @@ export class AggregatorService { ); } - this.coinPriceHistoryService.createOrUpdate({ + await this.coinPriceHistoryService.createOrUpdate({ coin, currency: CurrencyType[currency], price, diff --git a/apps/api/src/api.module.ts b/apps/api/src/api.module.ts index ec987b9..9ffa1e2 100644 --- a/apps/api/src/api.module.ts +++ b/apps/api/src/api.module.ts @@ -19,7 +19,9 @@ import { ApiValidationSchema } from '@dao-stats/config/validation/api.schema'; import { HttpCacheModule } from '@dao-stats/cache'; import { Contract, + ContractModule, DaoContractContext, + DaoModule, Receipt, ReceiptAction, Transaction, @@ -31,7 +33,7 @@ import { DaoContractContextInterceptor, HttpCacheInterceptor, } from './interceptors'; -import { ContractModule } from './contract/contract.module'; +import { ApiContractModule } from './contract/contract.module'; import { GeneralModule } from './general/general.module'; import { UsersModule } from './users/users.module'; import { GovernanceModule } from './governance/governance.module'; @@ -60,9 +62,11 @@ import { MarketModule } from './market/market.module'; useClass: TypeOrmConfigService, }), TypeOrmModule.forFeature([Contract, Receipt, ReceiptAction, Transaction]), + ContractModule, + DaoModule, HttpCacheModule, RedisModule, - ContractModule, + ApiContractModule, ApiDaoModule, GeneralModule, UsersModule, diff --git a/apps/api/src/contract/contract.controller.ts b/apps/api/src/contract/contract.controller.ts index f82baca..f299b13 100644 --- a/apps/api/src/contract/contract.controller.ts +++ b/apps/api/src/contract/contract.controller.ts @@ -1,7 +1,6 @@ import { Controller, Get } from '@nestjs/common'; import { ApiBadRequestResponse, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { ContractResponse } from './dto'; -import { ContractService } from './contract.service'; +import { ContractDto, ContractService } from '@dao-stats/common'; import { NoContractContext } from '../decorators'; @ApiTags('Contracts') @@ -11,14 +10,14 @@ export class ContractController { @ApiResponse({ status: 200, - type: [ContractResponse], + type: [ContractDto], }) @ApiBadRequestResponse({ description: 'Bad Request Response based on the query params set', }) @NoContractContext() @Get() - async contracts(): Promise { + async contracts(): Promise { return this.contractService.find(); } } diff --git a/apps/api/src/contract/contract.module.ts b/apps/api/src/contract/contract.module.ts index 4c60c68..35e0772 100644 --- a/apps/api/src/contract/contract.module.ts +++ b/apps/api/src/contract/contract.module.ts @@ -1,21 +1,17 @@ -import { TypeOrmModule } from '@nestjs/typeorm'; import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; -import { Contract } from '@dao-stats/common'; +import { ContractModule } from '@dao-stats/common'; import { ContractController } from './contract.controller'; -import { ContractService } from './contract.service'; @Module({ imports: [ CacheModule.registerAsync({ useClass: CacheConfigService, }), - TypeOrmModule.forFeature([Contract]), + ContractModule, ], - providers: [ContractService], controllers: [ContractController], - exports: [ContractService], }) -export class ContractModule {} +export class ApiContractModule {} diff --git a/apps/api/src/contract/dto/index.ts b/apps/api/src/contract/dto/index.ts deleted file mode 100644 index 5ee7fed..0000000 --- a/apps/api/src/contract/dto/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './contract.dto'; diff --git a/apps/api/src/dao/dao.module.ts b/apps/api/src/dao/dao.module.ts index e05e72c..8fdd887 100644 --- a/apps/api/src/dao/dao.module.ts +++ b/apps/api/src/dao/dao.module.ts @@ -1,22 +1,18 @@ -import { TypeOrmModule } from '@nestjs/typeorm'; import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; -import { Dao, DaoService } from '@dao-stats/common'; +import { ContractModule, DaoModule } from '@dao-stats/common'; import { DaoController } from './dao.controller'; -import { ContractModule } from '../contract/contract.module'; @Module({ imports: [ CacheModule.registerAsync({ useClass: CacheConfigService, }), - TypeOrmModule.forFeature([Dao]), ContractModule, + DaoModule, ], - providers: [DaoService], controllers: [DaoController], - exports: [DaoService], }) export class ApiDaoModule {} diff --git a/apps/api/src/general/general.module.ts b/apps/api/src/general/general.module.ts index c051ab3..7a59b9b 100644 --- a/apps/api/src/general/general.module.ts +++ b/apps/api/src/general/general.module.ts @@ -1,11 +1,14 @@ import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; -import { DaoStatsModule, DaoStatsHistoryModule } from '@dao-stats/common'; +import { + ContractModule, + DaoStatsModule, + DaoStatsHistoryModule, +} from '@dao-stats/common'; import { TransactionModule } from '@dao-stats/transaction'; import { GeneralController } from './general.controller'; import { GeneralService } from './general.service'; -import { ContractModule } from '../contract/contract.module'; import { MetricService } from '../common/metric.service'; @Module({ diff --git a/apps/api/src/governance/governance.module.ts b/apps/api/src/governance/governance.module.ts index 27a2f69..e4ed5dc 100644 --- a/apps/api/src/governance/governance.module.ts +++ b/apps/api/src/governance/governance.module.ts @@ -1,12 +1,15 @@ import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; -import { DaoStatsModule, DaoStatsHistoryModule } from '@dao-stats/common'; +import { + ContractModule, + DaoStatsModule, + DaoStatsHistoryModule, +} from '@dao-stats/common'; import { TransactionModule } from '@dao-stats/transaction'; import { GovernanceController } from './governance.controller'; import { GovernanceService } from './governance.service'; -import { ContractModule } from '../contract/contract.module'; import { MetricService } from '../common/metric.service'; @Module({ diff --git a/apps/api/src/governance/governance.service.ts b/apps/api/src/governance/governance.service.ts index ddd6ed2..1dcbb4a 100644 --- a/apps/api/src/governance/governance.service.ts +++ b/apps/api/src/governance/governance.service.ts @@ -16,10 +16,12 @@ import { TransactionType, } from '@dao-stats/common'; import { TransactionService } from '@dao-stats/transaction'; -import { GovernanceTotalResponse } from './dto/governance-total.dto'; -import { ProposalsTypesLeaderboardResponse } from './dto/proposals-types-leaderboard-response.dto'; -import { ProposalsTypesHistoryResponse } from './dto/proposals-types-history-response.dto'; -import { VoteRateLeaderboardResponse } from './dto/vote-rate-leaderboard-response.dto'; +import { + GovernanceTotalResponse, + ProposalsTypesHistoryResponse, + ProposalsTypesLeaderboardResponse, + VoteRateLeaderboardResponse, +} from './dto'; import { MetricService } from '../common/metric.service'; import { getGrowth, getRate, patchMetricDays } from '../utils'; diff --git a/apps/api/src/interceptors/contract-context.interceptor.ts b/apps/api/src/interceptors/contract-context.interceptor.ts index dffb98e..dfd5d18 100644 --- a/apps/api/src/interceptors/contract-context.interceptor.ts +++ b/apps/api/src/interceptors/contract-context.interceptor.ts @@ -9,8 +9,11 @@ import { } from '@nestjs/common'; import { RequestContext } from '@medibloc/nestjs-request-context'; -import { ContractContext, NO_CONTRACT_CONTEXT } from '@dao-stats/common'; -import { ContractService } from '../contract/contract.service'; +import { + ContractContext, + ContractService, + NO_CONTRACT_CONTEXT, +} from '@dao-stats/common'; @Injectable() export class ContractContextInterceptor implements NestInterceptor { diff --git a/apps/api/src/market/dto/coin-price-history.dto.ts b/apps/api/src/market/dto/coin-price-history.dto.ts index b448996..c36367f 100644 --- a/apps/api/src/market/dto/coin-price-history.dto.ts +++ b/apps/api/src/market/dto/coin-price-history.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; -import { CoinType, CurrencyType } from '@dao-stats/common/types'; +import { CoinType, CurrencyType } from '@dao-stats/common'; export class CoinPriceHistoryResponse { @ApiProperty() diff --git a/apps/api/src/market/market.controller.ts b/apps/api/src/market/market.controller.ts index 2c3e883..68ab64a 100644 --- a/apps/api/src/market/market.controller.ts +++ b/apps/api/src/market/market.controller.ts @@ -6,8 +6,7 @@ import { ApiTags, } from '@nestjs/swagger'; -import { CoinType } from '@dao-stats/common/types'; -import { CoinPriceQuery } from '@dao-stats/common/dto'; +import { CoinType, CoinPriceQuery } from '@dao-stats/common'; import { MarketService } from './market.service'; import { NoContractContext } from '../decorators'; diff --git a/apps/api/src/market/market.service.ts b/apps/api/src/market/market.service.ts index fe3bfe2..7d292b2 100644 --- a/apps/api/src/market/market.service.ts +++ b/apps/api/src/market/market.service.ts @@ -1,9 +1,11 @@ import { Injectable } from '@nestjs/common'; import moment from 'moment'; -import { CoinPriceHistoryService } from '@dao-stats/common'; -import { CoinPriceQuery } from '@dao-stats/common/dto'; -import { CoinType } from '@dao-stats/common/types'; +import { + CoinPriceHistoryService, + CoinPriceQuery, + CoinType, +} from '@dao-stats/common'; import { CoinPriceHistoryResponse } from './dto'; diff --git a/apps/api/src/tokens/tokens.module.ts b/apps/api/src/tokens/tokens.module.ts index 3786426..1e4f59c 100644 --- a/apps/api/src/tokens/tokens.module.ts +++ b/apps/api/src/tokens/tokens.module.ts @@ -1,12 +1,15 @@ import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; -import { DaoStatsHistoryModule, DaoStatsModule } from '@dao-stats/common'; +import { + ContractModule, + DaoStatsHistoryModule, + DaoStatsModule, +} from '@dao-stats/common'; import { TransactionModule } from '@dao-stats/transaction'; import { TokensController } from './tokens.controller'; import { TokensService } from './tokens.service'; -import { ContractModule } from '../contract/contract.module'; import { MetricService } from '../common/metric.service'; @Module({ diff --git a/apps/api/src/tvl/tvl.module.ts b/apps/api/src/tvl/tvl.module.ts index b1dd108..2dc3a20 100644 --- a/apps/api/src/tvl/tvl.module.ts +++ b/apps/api/src/tvl/tvl.module.ts @@ -2,15 +2,15 @@ import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; import { + CoinPriceHistoryModule, + ContractModule, DaoStatsHistoryModule, DaoStatsModule, - CoinPriceHistoryModule, } from '@dao-stats/common'; import { TransactionModule } from '@dao-stats/transaction'; import { TvlController } from './tvl.controller'; import { TvlService } from './tvl.service'; -import { ContractModule } from '../contract/contract.module'; import { MetricService } from '../common/metric.service'; @Module({ diff --git a/apps/api/src/users/users.module.ts b/apps/api/src/users/users.module.ts index d1957c1..4a76e0a 100644 --- a/apps/api/src/users/users.module.ts +++ b/apps/api/src/users/users.module.ts @@ -1,12 +1,15 @@ import { CacheModule, Module } from '@nestjs/common'; import { CacheConfigService } from '@dao-stats/config/cache'; -import { DaoStatsHistoryModule, DaoStatsModule } from '@dao-stats/common'; +import { + ContractModule, + DaoStatsHistoryModule, + DaoStatsModule, +} from '@dao-stats/common'; import { TransactionModule } from '@dao-stats/transaction'; import { UsersController } from './users.controller'; import { UsersService } from './users.service'; -import { ContractModule } from '../contract/contract.module'; import { MetricService } from '../common/metric.service'; @Module({ diff --git a/libs/astro/src/astro.module.ts b/libs/astro/src/astro.module.ts index 044f35b..25bacc9 100644 --- a/libs/astro/src/astro.module.ts +++ b/libs/astro/src/astro.module.ts @@ -4,11 +4,12 @@ import { NearModule } from '@dao-stats/near'; import { AstroService } from './astro.service'; import configuration from './config/configuration'; +import exchange from '@dao-stats/config/exchange-config'; @Module({ imports: [ ConfigModule.forRoot({ - load: [configuration], + load: [configuration, exchange], }), NearModule, ], diff --git a/libs/common/src/coin-price-history.service.ts b/libs/common/src/coin-price-history.service.ts index 8943e68..e771cd4 100644 --- a/libs/common/src/coin-price-history.service.ts +++ b/libs/common/src/coin-price-history.service.ts @@ -2,9 +2,8 @@ import { Connection, InsertResult, Repository } from 'typeorm'; import { Injectable } from '@nestjs/common'; import { InjectConnection, InjectRepository } from '@nestjs/typeorm'; -import { CoinPriceHistory } from './entities/coin-price-history.entity'; -import { CoinType } from './types/coin-type'; -import { CurrencyType } from './types/currency-type'; +import { CoinPriceHistory } from './entities'; +import { CoinType, CurrencyType } from './types'; @Injectable() export class CoinPriceHistoryService { diff --git a/libs/common/src/contract.module.ts b/libs/common/src/contract.module.ts new file mode 100644 index 0000000..3f45372 --- /dev/null +++ b/libs/common/src/contract.module.ts @@ -0,0 +1,12 @@ +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Module } from '@nestjs/common'; + +import { Contract } from './entities'; +import { ContractService } from './contract.service'; + +@Module({ + imports: [TypeOrmModule.forFeature([Contract])], + providers: [ContractService], + exports: [ContractService], +}) +export class ContractModule {} diff --git a/apps/api/src/contract/contract.service.ts b/libs/common/src/contract.service.ts similarity index 64% rename from apps/api/src/contract/contract.service.ts rename to libs/common/src/contract.service.ts index 8e3f438..200b422 100644 --- a/apps/api/src/contract/contract.service.ts +++ b/libs/common/src/contract.service.ts @@ -1,25 +1,22 @@ import { Repository } from 'typeorm'; import { Injectable } from '@nestjs/common'; -import { ConfigService } from '@nestjs/config'; import { InjectRepository } from '@nestjs/typeorm'; import { Contract } from '@dao-stats/common'; -import { ContractResponse } from './dto'; +import { ContractDto } from './dto'; @Injectable() export class ContractService { constructor( - private readonly configService: ConfigService, - @InjectRepository(Contract) private readonly contractRepository: Repository, ) {} - async find(): Promise { + async find(): Promise { return this.contractRepository.find(); } - async findById(contractId: string): Promise { + async findById(contractId: string): Promise { return this.contractRepository.findOne({ contractId }); } } diff --git a/libs/common/src/dto/coin-price-query.dto.ts b/libs/common/src/dto/coin-price-query.dto.ts index 1d514d2..b94d33d 100644 --- a/libs/common/src/dto/coin-price-query.dto.ts +++ b/libs/common/src/dto/coin-price-query.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { MetricQuery } from '.'; +import { MetricQuery } from './metric-query.dto'; import { CurrencyType } from '../types/currency-type'; export class CoinPriceQuery extends MetricQuery { diff --git a/apps/api/src/contract/dto/contract.dto.ts b/libs/common/src/dto/contract.dto.ts similarity index 72% rename from apps/api/src/contract/dto/contract.dto.ts rename to libs/common/src/dto/contract.dto.ts index 952de5d..efd99c3 100644 --- a/apps/api/src/contract/dto/contract.dto.ts +++ b/libs/common/src/dto/contract.dto.ts @@ -1,7 +1,7 @@ -import { CoinType } from '@dao-stats/common/types/coin-type'; import { ApiProperty } from '@nestjs/swagger'; +import { CoinType } from '../types/coin-type'; -export class ContractResponse { +export class ContractDto { @ApiProperty() contractId: string; diff --git a/libs/common/src/dto/index.ts b/libs/common/src/dto/index.ts index 89b880b..789c135 100644 --- a/libs/common/src/dto/index.ts +++ b/libs/common/src/dto/index.ts @@ -1,3 +1,5 @@ +export * from './coin-price-query.dto'; +export * from './contract.dto'; export * from './contract-context.dto'; export * from './daily-count.dto'; export * from './daily-metric.dto'; @@ -14,4 +16,3 @@ export * from './receipt.dto'; export * from './receipt-action.dto'; export * from './total.dto'; export * from './transaction.dto'; -export * from './coin-price-query.dto'; diff --git a/libs/common/src/entities/index.ts b/libs/common/src/entities/index.ts index 407250f..4e00341 100644 --- a/libs/common/src/entities/index.ts +++ b/libs/common/src/entities/index.ts @@ -1,4 +1,5 @@ export * from './base.entity'; +export * from './coin-price-history.entity'; export * from './contract.entity'; export * from './dao.entity'; export * from './dao-stats.entity'; diff --git a/libs/common/src/index.ts b/libs/common/src/index.ts index ae560f0..470b035 100644 --- a/libs/common/src/index.ts +++ b/libs/common/src/index.ts @@ -3,6 +3,8 @@ export * from './entities'; export * from './interfaces'; export * from './types'; export * from './constants'; +export * from './contract.service'; +export * from './contract.module'; export * from './dao.module'; export * from './dao.service'; export * from './dao-stats.service'; diff --git a/libs/config/src/validation/aggregator.schema.ts b/libs/config/src/validation/aggregator.schema.ts index ab9ba75..caadb91 100644 --- a/libs/config/src/validation/aggregator.schema.ts +++ b/libs/config/src/validation/aggregator.schema.ts @@ -9,4 +9,12 @@ export class AggregatorValidationSchema extends DatabaseValidationSchema { @IsString() @IsNotEmpty() REDIS_EVENT_BUS_URL: string; + + @IsString() + @IsNotEmpty() + SODAKI_API_BASE_URL: string; + + @IsString() + @IsNotEmpty() + COINGECKO_API_BASE_URL: string; } diff --git a/libs/exchange/src/coin-gecko.service.ts b/libs/exchange/src/coin-gecko.service.ts index 395455e..b789fac 100644 --- a/libs/exchange/src/coin-gecko.service.ts +++ b/libs/exchange/src/coin-gecko.service.ts @@ -3,8 +3,7 @@ import { HttpService } from '@nestjs/axios'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Cacheable } from '@type-cacheable/core'; -import { CoinType } from '@dao-stats/common/types/coin-type'; -import { CurrencyType } from '@dao-stats/common/types/currency-type'; +import { CoinType, CurrencyType } from '@dao-stats/common'; import { ExchangeConfig } from '@dao-stats/config/exchange-config'; @Injectable() diff --git a/libs/exchange/src/exchange.module.ts b/libs/exchange/src/exchange.module.ts index 9db2ea1..444d8ed 100644 --- a/libs/exchange/src/exchange.module.ts +++ b/libs/exchange/src/exchange.module.ts @@ -2,7 +2,8 @@ import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; import { ConfigModule } from '@nestjs/config'; -import { CoinGeckoService, SodakiService } from '.'; +import { CoinGeckoService } from './coin-gecko.service'; +import { SodakiService } from './sodaki.service'; @Module({ imports: [ConfigModule, HttpModule], diff --git a/libs/exchange/src/index.ts b/libs/exchange/src/index.ts index 26b08d5..b3466d2 100644 --- a/libs/exchange/src/index.ts +++ b/libs/exchange/src/index.ts @@ -1,2 +1,4 @@ -export * from './sodaki.service'; +export * from './types'; export * from './coin-gecko.service'; +export * from './exchange.module'; +export * from './sodaki.service'; diff --git a/libs/exchange/src/sodaki.service.ts b/libs/exchange/src/sodaki.service.ts index 9ec3870..30058d1 100644 --- a/libs/exchange/src/sodaki.service.ts +++ b/libs/exchange/src/sodaki.service.ts @@ -3,10 +3,9 @@ import { HttpService } from '@nestjs/axios'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Cacheable } from '@type-cacheable/core'; -import { CoinType } from '@dao-stats/common/types/coin-type'; -import { CurrencyType } from '@dao-stats/common/types/currency-type'; -import { SodakiCoinTypeSymbol } from './types/sodaki-coin-type-symbol'; +import { CoinType, CurrencyType } from '@dao-stats/common'; import { ExchangeConfig } from '@dao-stats/config/exchange-config'; +import { SodakiCoinTypeSymbol } from './types'; @Injectable() export class SodakiService { diff --git a/libs/exchange/src/types/index.ts b/libs/exchange/src/types/index.ts new file mode 100644 index 0000000..6879be6 --- /dev/null +++ b/libs/exchange/src/types/index.ts @@ -0,0 +1 @@ +export * from './sodaki-coin-type-symbol'; diff --git a/libs/migrations/src/migration.module.ts b/libs/migrations/src/migration.module.ts index 55a5150..ec075f9 100644 --- a/libs/migrations/src/migration.module.ts +++ b/libs/migrations/src/migration.module.ts @@ -7,15 +7,16 @@ import configuration, { } from '@dao-stats/config/aggregator-config'; import { HttpCacheModule } from '@dao-stats/cache'; import { + CoinPriceHistoryModule, Contract, - Transaction, + ContractModule, + DaoStatsHistoryModule, Receipt, ReceiptAction, - DaoStatsHistoryModule, + Transaction, } from '@dao-stats/common'; +import { ExchangeModule } from '@dao-stats/exchange'; import migrationScripts from './scripts'; -import { ExchangeModule } from 'libs/exchange/src/exchange.module'; -import { CoinPriceHistoryModule } from '@dao-stats/common/coin-price-history.module'; @Module({ imports: [ @@ -28,6 +29,7 @@ import { CoinPriceHistoryModule } from '@dao-stats/common/coin-price-history.mod envFilePath: ['.env.local', '.env'], }), TypeOrmModule.forFeature([Contract, Transaction, Receipt, ReceiptAction]), + ContractModule, DaoStatsHistoryModule, HttpCacheModule, ExchangeModule, diff --git a/libs/migrations/src/scripts/historical-aggregation.migration.ts b/libs/migrations/src/scripts/historical-aggregation.migration.ts index 67e8a72..7bea14f 100644 --- a/libs/migrations/src/scripts/historical-aggregation.migration.ts +++ b/libs/migrations/src/scripts/historical-aggregation.migration.ts @@ -1,9 +1,13 @@ import { ConfigService } from '@nestjs/config'; import { LazyModuleLoader } from '@nestjs/core'; import { Injectable, Logger } from '@nestjs/common'; -import { Migration } from '..'; import { CacheService } from '@dao-stats/cache'; -import { Aggregator, DaoStatsHistoryService } from '@dao-stats/common'; +import { + Aggregator, + ContractService, + DaoStatsHistoryService, +} from '@dao-stats/common'; +import { Migration } from '..'; @Injectable() export class HistoricalAggregationMigration implements Migration { @@ -13,13 +17,14 @@ export class HistoricalAggregationMigration implements Migration { private readonly configService: ConfigService, private readonly cacheService: CacheService, private readonly lazyModuleLoader: LazyModuleLoader, + private readonly contractService: ContractService, private readonly daoStatsHistoryService: DaoStatsHistoryService, ) {} public async migrate(): Promise { - const { smartContracts } = this.configService.get('aggregator'); + const contracts = await this.contractService.find(); - for (const contractId of smartContracts) { + for (const { contractId } of contracts) { this.logger.log(`Processing contract: ${contractId}...`); const { AggregationModule, AggregationService } = await import( diff --git a/libs/migrations/src/scripts/near-price-history.migration.ts b/libs/migrations/src/scripts/near-price-history.migration.ts index ce14512..4ca509d 100644 --- a/libs/migrations/src/scripts/near-price-history.migration.ts +++ b/libs/migrations/src/scripts/near-price-history.migration.ts @@ -1,12 +1,14 @@ import { Repository } from 'typeorm'; import { Injectable, Logger } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { Transaction } from '@dao-stats/common'; +import { + CoinPriceHistoryService, + CoinType, + CurrencyType, + Transaction, +} from '@dao-stats/common'; +import { CoinGeckoService } from '@dao-stats/exchange'; import { Migration } from '..'; -import { CoinPriceHistoryService } from '@dao-stats/common/coin-price-history.service'; -import { CoinGeckoService } from 'libs/exchange/src'; -import { CoinType } from '@dao-stats/common/types/coin-type'; -import { CurrencyType } from '@dao-stats/common/types/currency-type'; @Injectable() export class NearPriceHistoryMigration implements Migration { diff --git a/libs/receipt/src/receipt.module.ts b/libs/receipt/src/receipt.module.ts index 148a0a3..93119fc 100644 --- a/libs/receipt/src/receipt.module.ts +++ b/libs/receipt/src/receipt.module.ts @@ -1,8 +1,12 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { Contract, Receipt, ReceiptAction } from '@dao-stats/common'; +import { + Contract, + ContractModule, + Receipt, + ReceiptAction, +} from '@dao-stats/common'; -import { ContractModule } from 'apps/api/src/contract/contract.module'; import { ReceiptActionService } from './receipt-action.service'; @Module({