Skip to content

Commit

Permalink
refactor: apply yarn lint
Browse files Browse the repository at this point in the history
  • Loading branch information
moreal committed Dec 10, 2024
1 parent 8394f6c commit 8a84896
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 74 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "biome format --write",
"lint": "biome check --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
Expand Down
2 changes: 1 addition & 1 deletion src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Test, type TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';

Expand Down
2 changes: 1 addition & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import type { AppService } from './app.service';

@Controller()
export class AppController {
Expand Down
24 changes: 14 additions & 10 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PrismaModule } from './prisma/prisma.module';
import { JobModule } from './job/job.module';
import { ScheduleModule } from '@nestjs/schedule';
import { QueueModule } from './queue/queue.module';
import { TransactionModule } from './transaction/transaction.module';
import { ConfigModule } from '@nestjs/config';
import { TxModule } from './tx/tx.module';
import { CacheModule } from '@nestjs/cache-manager';
import {
type MiddlewareConsumer,
Module,
type NestModule,
} from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import {
PrometheusModule,
makeCounterProvider,
} from '@willsoto/nestjs-prometheus';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { HttpResponseMiddleware } from './http-response.middleware';
import { JobModule } from './job/job.module';
import { PrismaModule } from './prisma/prisma.module';
import { QueueModule } from './queue/queue.module';
import { TransactionModule } from './transaction/transaction.module';
import { TxModule } from './tx/tx.module';

@Module({
imports: [
Expand Down
14 changes: 9 additions & 5 deletions src/common/guards/auth.guard.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
type CanActivate,
type ExecutionContext,
Injectable,
} from '@nestjs/common';
import type { Reflector } from '@nestjs/core';
import type { Request } from 'express';
import type { PrismaService } from 'src/prisma/prisma.service';
import { RequireAuthToken } from '../decorators/required-auth-token.decorator';
import { PrismaService } from 'src/prisma/prisma.service';
import { Request } from 'express';

@Injectable()
export class AuthGuard implements CanActivate {
Expand All @@ -23,7 +27,7 @@ export class AuthGuard implements CanActivate {
}

const splat = header.split(' ');
if (splat.length == 2 && splat[0] == 'Bearer') {
if (splat.length === 2 && splat[0] === 'Bearer') {
const authToken = await this.prismaSerivce.authToken.findUnique({
where: {
token: splat[1],
Expand Down
8 changes: 4 additions & 4 deletions src/http-response.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Injectable, type NestMiddleware } from '@nestjs/common';
import { InjectMetric } from '@willsoto/nestjs-prometheus';
import { Request, Response } from 'express';
import { Counter } from 'prom-client';
import type { Request, Response } from 'express';
import type { Counter } from 'prom-client';

@Injectable()
export class HttpResponseMiddleware implements NestMiddleware {
Expand All @@ -12,7 +12,7 @@ export class HttpResponseMiddleware implements NestMiddleware {
private readonly httpResponseCounter: Counter<string>,
) {}

use(req: Request, res: Response, next: (error?: any) => void) {
use(req: Request, res: Response, next: (error?: unknown) => void) {
if (req.baseUrl === '/metrics') return next();

this.httpRequestCounter
Expand Down
8 changes: 4 additions & 4 deletions src/job/dto/create-transfer-assets.dto.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Type } from 'class-transformer';
import {
IsDefined,
IsHexadecimal,
IsNumberString,
IsObject,
IsString,
Length,
ValidateIf,
ValidateNested,
IsHexadecimal,
Length,
IsDefined,
IsNumberString,
} from 'class-validator';
import {
IsTicker,
Expand Down
2 changes: 1 addition & 1 deletion src/job/job-status.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TxResult } from '@prisma/client';
import type { TxResult } from '@prisma/client';

export enum JobStatus {
PENDING = 'PENDING',
Expand Down
8 changes: 4 additions & 4 deletions src/job/job.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { JobService } from './job.service';
import { CreateClaimItemsDto } from './dto/create-claim-items.dto';
import { CreateTransferAssetsDto } from './dto/create-transfer-assets.dto';
import { RequireAuthToken } from 'src/common/decorators/required-auth-token.decorator';
import { AuthGuard } from 'src/common/guards/auth.guard';
import { CreateClaimItemsEventDto } from './dto/create-claim-items-event.dto';
import type { CreateClaimItemsEventDto } from './dto/create-claim-items-event.dto';
import type { CreateClaimItemsDto } from './dto/create-claim-items.dto';
import type { CreateTransferAssetsDto } from './dto/create-transfer-assets.dto';
import type { JobService } from './job.service';

@UseGuards(AuthGuard)
@Controller('jobs')
Expand Down
2 changes: 1 addition & 1 deletion src/job/job.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { TxModule } from 'src/tx/tx.module';
import { JobController } from './job.controller';
import { JobService } from './job.service';
import { TxModule } from 'src/tx/tx.module';

@Module({
imports: [TxModule],
Expand Down
14 changes: 7 additions & 7 deletions src/job/job.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { randomUUID } from 'node:crypto';
import {
BadRequestException,
Injectable,
Logger,
NotFoundException,
} from '@nestjs/common';
import { PrismaService } from 'src/prisma/prisma.service';
import { CreateClaimItemsDto } from './dto/create-claim-items.dto';
import { CreateTransferAssetsDto } from './dto/create-transfer-assets.dto';
import type { Job, TxResult } from '@prisma/client';
import type { PrismaService } from 'src/prisma/prisma.service';
import type { TxService } from 'src/tx/tx.service';
import { getCurrency } from 'src/utils/currency';
import type { CreateClaimItemsEventDto } from './dto/create-claim-items-event.dto';
import type { CreateClaimItemsDto } from './dto/create-claim-items.dto';
import type { CreateTransferAssetsDto } from './dto/create-transfer-assets.dto';
import { JobStatus, getJobStatusFromTxResult } from './job-status.entity';
import { TxService } from 'src/tx/tx.service';
import { Job, TxResult } from '@prisma/client';
import { CreateClaimItemsEventDto } from './dto/create-claim-items-event.dto';
import { randomUUID } from 'crypto';

@Injectable()
export class JobService {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';

import * as dotenv from 'dotenv';

Expand Down
2 changes: 1 addition & 1 deletion src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
import { Injectable, type OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';

@Injectable()
Expand Down
8 changes: 4 additions & 4 deletions src/queue/queue.cron.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CACHE_MANAGER } from '@nestjs/cache-manager';
import { Inject, Injectable } from '@nestjs/common';
import { QueueService } from './queue.service';
import { Cron, CronExpression } from '@nestjs/schedule';
import { Cache } from 'cache-manager';
import { CACHE_MANAGER } from '@nestjs/cache-manager';
import { InjectMetric } from '@willsoto/nestjs-prometheus';
import { Gauge } from 'prom-client';
import type { Cache } from 'cache-manager';
import type { Gauge } from 'prom-client';
import type { QueueService } from './queue.service';

const handleCronLock = 'HANDLE_CRON_LOCK';
const handleStagingCronLock = 'HANDLE_STAGING_CRON_LOCK';
Expand Down
6 changes: 3 additions & 3 deletions src/queue/queue.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from '@nestjs/common';
import { QueueService } from './queue.service';
import { QueueCronController } from './queue.cron';
import { TxModule } from 'src/tx/tx.module';
import { ConfigModule } from '@nestjs/config';
import { makeGaugeProvider } from '@willsoto/nestjs-prometheus';
import { TxModule } from 'src/tx/tx.module';
import { QueueCronController } from './queue.cron';
import { QueueService } from './queue.service';

@Module({
imports: [TxModule, ConfigModule],
Expand Down
8 changes: 4 additions & 4 deletions src/queue/queue.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ActionType, Job, Prisma } from '@prisma/client';
import type { ConfigService } from '@nestjs/config';
import { ActionType, type Job, Prisma } from '@prisma/client';

import { PrismaService } from 'src/prisma/prisma.service';
import { TxService } from 'src/tx/tx.service';
import type { PrismaService } from 'src/prisma/prisma.service';
import type { TxService } from 'src/tx/tx.service';

const DEFAULT_TX_ACTIONS_SIZE = 100;
const JOT_RETRY_LIMIT = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/transaction.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get, Param } from '@nestjs/common';
import { TransactionService } from './transaction.service';
import type { TransactionService } from './transaction.service';

@Controller('transactions')
export class TransactionController {
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/transaction.cron.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { TransactionService } from './transaction.service';
import { Cron, CronExpression } from '@nestjs/schedule';
import type { TransactionService } from './transaction.service';

@Injectable()
export class TransactionCronController {
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/transaction.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common';
import { TransactionService } from './transaction.service';
import { TxModule } from 'src/tx/tx.module';
import { TransactionController } from './transaction.controller';
import { TransactionCronController } from './transaction.cron';
import { TxModule } from 'src/tx/tx.module';
import { TransactionService } from './transaction.service';

@Module({
imports: [TxModule],
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from '@nestjs/common';
import { TxResult } from '@prisma/client';
import { getJobStatusFromTxResult } from 'src/job/job-status.entity';
import { PrismaService } from 'src/prisma/prisma.service';
import { TxService } from 'src/tx/tx.service';
import type { PrismaService } from 'src/prisma/prisma.service';
import type { TxService } from 'src/tx/tx.service';

const UPDATE_TRANSACTIONS_SIZE = 10;

Expand Down
8 changes: 5 additions & 3 deletions src/tx/action.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { randomUUID } from 'node:crypto';
import { Injectable } from '@nestjs/common';
import { BencodexDictionary } from '@planetarium/bencodex';
import type { Job } from '@prisma/client';
import { Decimal } from 'decimal.js';
import { randomUUID } from 'node:crypto';

import { CURRENCIES } from './tx.constants';
import type { Address as AddressType } from '@planetarium/account';
import { CURRENCIES } from './tx.constants';

import { Address } from '@planetarium/account';
import { encodeCurrency } from '@planetarium/tx';
Expand Down Expand Up @@ -100,7 +100,9 @@ export class ActionService {
guid.split('-').reduce((bytes, section, index) => {
const bytesInChar = section.match(/.{1,2}/g);
if (index < 3) bytesInChar.reverse();
return bytes.concat(bytesInChar.map((byte) => parseInt(byte, 16)));
return bytes.concat(
bytesInChar.map((byte) => Number.parseInt(byte, 16)),
);
}, []),
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tx/tx.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { TxService } from './tx.service';
import { ConfigModule } from '@nestjs/config';
import { ActionService } from './action.service';
import { HttpModule } from '@nestjs/axios';
import { TxService } from './tx.service';

@Module({
imports: [
Expand Down
20 changes: 10 additions & 10 deletions src/tx/tx.service.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { createHash } from 'node:crypto';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import type { Job, TxResult } from '@prisma/client';
import type { ConfigService } from '@nestjs/config';
import type { Account } from '@planetarium/account';
import { BencodexDictionary, type Value, encode } from '@planetarium/bencodex';
import type { UnsignedTx } from '@planetarium/tx/dist/tx';
import { BencodexDictionary, Value, encode } from '@planetarium/bencodex';
import { createHash } from 'node:crypto';
import type { Job, TxResult } from '@prisma/client';

import { CURRENCIES, SUPER_FUTURE_DATETIME } from './tx.constants';
import { ActionService } from './action.service';
import { Tx } from './tx.entity';
import { HttpService } from '@nestjs/axios';
import type { HttpService } from '@nestjs/axios';
import { firstValueFrom } from 'rxjs';
import type { ActionService } from './action.service';
import { CURRENCIES, SUPER_FUTURE_DATETIME } from './tx.constants';
import type { Tx } from './tx.entity';

import { Address, PublicKey } from '@planetarium/account';
import { AwsKmsAccount, KMSClient } from '@planetarium/account-aws-kms';
Expand Down Expand Up @@ -138,8 +138,8 @@ export class TxService {
genesisHash: genesisHash,
gasLimit: this.assumeGasLimit(action),
maxGasPrice: {
currency: CURRENCIES['MEAD'],
rawValue: BigInt(Math.pow(10, 18)),
currency: CURRENCIES.MEAD,
rawValue: 10n ** 18n,
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/currency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValidationOptions, registerDecorator } from 'class-validator';
import { type ValidationOptions, registerDecorator } from 'class-validator';

type Currency = {
type: 'constant' | 'prefix' | 'string_prefix';
Expand Down

0 comments on commit 8a84896

Please sign in to comment.