diff --git a/src/app.module.ts b/src/app.module.ts index 82ee0f1b..b5d7ae86 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,21 +1,24 @@ -import { CacheModule, Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { ScheduleModule } from '@nestjs/schedule'; -import { ConfigModule, ConfigService } from '@nestjs/config'; import { BullModule } from '@nestjs/bull'; -import { SharedModule } from './shared/shared.module'; -import { SeederModule } from './modules/seeders/seeder.module'; +import { CacheModule, Module } from '@nestjs/common'; +import { ConfigModule, ConfigService } from '@nestjs/config'; +import { ScheduleModule } from '@nestjs/schedule'; +import { TypeOrmModule } from '@nestjs/typeorm'; + import { AuthModule } from './modules/auth/auth.module'; -import { SafeModule } from './modules/safe/safe.module'; +import { JwtStrategy } from './modules/auth/jwt.strategy'; import { ChainModule } from './modules/chain/chain.module'; -import { MultisigTransactionModule } from './modules/multisig-transaction/multisig-transaction.module'; +import { NotifyProposalModule } from './modules/jobs/notify-proposal.module'; +import { + MultisigTransactionModule +} from './modules/multisig-transaction/multisig-transaction.module'; import { NotificationModule } from './modules/notification/notification.module'; import { SafeOwnerModule } from './modules/safe-owner/safe-owner.module'; +import { SafeModule } from './modules/safe/safe.module'; +import { SeederModule } from './modules/seeders/seeder.module'; import { UserModule } from './modules/user/user.module'; -import { JwtStrategy } from './modules/auth/jwt.strategy'; -import { NotifyProposalModule } from './modules/jobs/notify-proposal.module'; import { CustomConfigService } from './shared/services/custom-config.service'; +import { SharedModule } from './shared/shared.module'; @Module({ imports: [ @@ -39,6 +42,11 @@ import { CustomConfigService } from './shared/services/custom-config.service'; port: configService.get('REDIS_PORT'), db: configService.get('REDIS_DB'), }, + prefix: 'multisig', + defaultJobOptions: { + removeOnComplete: true, + removeOnFail: true + } }), inject: [ConfigService], }), @@ -58,7 +66,8 @@ import { CustomConfigService } from './shared/services/custom-config.service'; SafeOwnerModule, UserModule, NotifyProposalModule, + SeederModule ], providers: [JwtStrategy], }) -export class AppModule {} +export class AppModule { } diff --git a/src/main.ts b/src/main.ts index 2da86ce2..eaf3d267 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,13 +1,13 @@ -import { Logger, ValidationPipe } from '@nestjs/common'; +import bodyParser from 'body-parser'; +import { middleware as expressCtx } from 'express-ctx'; +import * as swaggerStats from 'swagger-stats'; + +import { ValidationPipe } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; -import { middleware as expressCtx } from 'express-ctx'; -import bodyParser from 'body-parser'; -import * as swaggerStats from 'swagger-stats'; + import { AppModule } from './app.module'; -import { SeederModule } from './modules/seeders/seeder.module'; -import { SeederService } from './modules/seeders/seeder.service'; import { SharedModule } from './shared/shared.module'; // eslint-disable-next-line no-void @@ -29,16 +29,6 @@ void (async function bootstrap() { const configService = app.select(SharedModule).get(ConfigService); - // create or update chain info - const seederService = app.select(SeederModule).get(SeederService); - try { - await seederService.seed(); - Logger.debug('Seed completed'); - } catch (error) { - Logger.error(error); - await app.close(); - } - // setup swagger const config = new DocumentBuilder() .setTitle('Multisig Wallet API for Aura Network') diff --git a/src/modules/multisig-transaction/multisig-transaction.module.ts b/src/modules/multisig-transaction/multisig-transaction.module.ts index bab35e02..7c9cc086 100644 --- a/src/modules/multisig-transaction/multisig-transaction.module.ts +++ b/src/modules/multisig-transaction/multisig-transaction.module.ts @@ -1,20 +1,21 @@ +import { BullModule } from '@nestjs/bull'; import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { BullModule } from '@nestjs/bull'; -import { MultisigTransactionService } from './multisig-transaction.service'; -import { MultisigTransactionController } from './multisig-transaction.controller'; -import { MultisigTransactionRepository } from './multisig-transaction.repository'; -import { MultisigTransaction } from './entities/multisig-transaction.entity'; + import { AuraTxModule } from '../aura-tx/aura-tx.module'; -import { MultisigConfirmModule } from '../multisig-confirm/multisig-confirm.module'; import { ChainModule } from '../chain/chain.module'; -import { SafeModule } from '../safe/safe.module'; -import { SafeOwnerModule } from '../safe-owner/safe-owner.module'; import { MessageModule } from '../message/message.module'; +import { MultisigConfirmModule } from '../multisig-confirm/multisig-confirm.module'; import { NotificationModule } from '../notification/notification.module'; -import { TransactionHistoryModule } from '../transaction-history/transaction-history.module'; +import { SafeOwnerModule } from '../safe-owner/safe-owner.module'; +import { SafeModule } from '../safe/safe.module'; import { SimulateModule } from '../simulate/simulate.module'; +import { TransactionHistoryModule } from '../transaction-history/transaction-history.module'; +import { MultisigTransaction } from './entities/multisig-transaction.entity'; +import { MultisigTransactionController } from './multisig-transaction.controller'; import { MultisigTxProcessor } from './multisig-transaction.processor'; +import { MultisigTransactionRepository } from './multisig-transaction.repository'; +import { MultisigTransactionService } from './multisig-transaction.service'; @Module({ imports: [ @@ -40,4 +41,4 @@ import { MultisigTxProcessor } from './multisig-transaction.processor'; ], exports: [MultisigTransactionRepository], }) -export class MultisigTransactionModule {} +export class MultisigTransactionModule { } diff --git a/src/modules/seeders/seeder.service.ts b/src/modules/seeders/seeder.service.ts index bd10954e..a38fbb9c 100644 --- a/src/modules/seeders/seeder.service.ts +++ b/src/modules/seeders/seeder.service.ts @@ -1,16 +1,18 @@ -import { Injectable } from '@nestjs/common'; import { validate } from 'class-validator'; -import { ChainRepository } from '../chain/chain.repository'; + +import { Injectable, OnModuleInit } from '@nestjs/common'; + import { CommonService } from '../../shared/services'; +import { ChainRepository } from '../chain/chain.repository'; @Injectable() -export class SeederService { +export class SeederService implements OnModuleInit { constructor( private chainRepo: ChainRepository, private commonSvc: CommonService, - ) {} + ) { } - async seed() { + async onModuleInit() { await this.seedChain(); } diff --git a/src/shared/services/indexer-v2.service.ts b/src/shared/services/indexer-v2.service.ts index 8c1296e8..0c3cbd8f 100644 --- a/src/shared/services/indexer-v2.service.ts +++ b/src/shared/services/indexer-v2.service.ts @@ -1,20 +1,16 @@ -import { Injectable, Logger } from '@nestjs/common'; import { isNumber } from 'lodash'; + +import { Injectable, Logger } from '@nestjs/common'; + import { CustomError } from '../../common/custom-error'; import { ErrorMap } from '../../common/error.map'; import { - IAccountInfo, - IAccounts, - IContractAddress, - IIndexerV2Response, - IProposal, - IProposals, - IPubkey, + IAccountInfo, IAccounts, IContractAddress, IIndexerV2Response, IProposal, IProposals, IPubkey } from '../../interfaces'; -import { IndexerResponseDto } from '../dtos'; -import { CommonService } from './common.service'; import { IAssetsWithType } from '../../interfaces/asset-by-owner.interface'; import { ChainInfo } from '../../utils/validations'; +import { IndexerResponseDto } from '../dtos'; +import { CommonService } from './common.service'; @Injectable() export class IndexerV2Client { @@ -22,7 +18,7 @@ export class IndexerV2Client { chainInfos: ChainInfo[]; - constructor(private commonService: CommonService) {} + constructor(private commonService: CommonService) { } async getCw20Contract(contractAddress: string, chainId: string) { const chainInfos = await this.commonService.readConfigurationFile(); @@ -205,6 +201,7 @@ export class IndexerV2Client { ): Promise { const chainInfos = await this.commonService.readConfigurationFile(); const selectedChain = chainInfos.find((e) => e.chainId === chainId); + if (!selectedChain) return []; const operationName = 'proposal'; const operatorDocs = ` query ${operationName}($limit: Int = 10, $order: order_by = desc, $proposalId: Int = null) {