Skip to content

Commit

Permalink
fix: rename blockDetail to blockDetails and txDetail to txDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Dec 5, 2023
1 parent bb7945e commit 3ef5a3e
Show file tree
Hide file tree
Showing 25 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/api/account/account.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mock } from "jest-mock-extended";
import { BadRequestException, Logger } from "@nestjs/common";
import { L2_ETH_TOKEN_ADDRESS } from "../../common/constants";
import { BlockService } from "../../block/block.service";
import { BlockDetail } from "../../block/blockDetail.entity";
import { BlockDetails } from "../../block/blockDetails.entity";
import { TransactionService } from "../../transaction/transaction.service";
import { BalanceService } from "../../balance/balance.service";
import { TransactionStatus } from "../../transaction/entities/transaction.entity";
Expand Down Expand Up @@ -629,7 +629,7 @@ describe("AccountController", () => {
it("returns blocks list response when block by miner are found", async () => {
jest
.spyOn(blockServiceMock, "findMany")
.mockResolvedValue([{ number: 1, timestamp: new Date("2023-03-03") } as BlockDetail]);
.mockResolvedValue([{ number: 1, timestamp: new Date("2023-03-03") } as BlockDetails]);
const response = await controller.getAccountMinedBlocks(address, {
page: 1,
offset: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from "@nestjs/common";
import { TransactionService } from "../../transaction/transaction.service";
import { TransactionReceiptService } from "../../transaction/transactionReceipt.service";
import { TransactionStatus } from "../../transaction/entities/transaction.entity";
import { TransactionDetail } from "../../transaction/entities/transactionDetail.entity";
import { TransactionDetails } from "../../transaction/entities/transactionDetails.entity";
import { TransactionReceipt } from "../../transaction/entities/transactionReceipt.entity";
import { ResponseStatus, ResponseMessage } from "../dtos/common/responseBase.dto";
import { TransactionController } from "./transaction.controller";
Expand Down Expand Up @@ -57,7 +57,7 @@ describe("TransactionController", () => {
it("returns isError as 0 when transaction is successful", async () => {
jest
.spyOn(transactionServiceMock, "findOne")
.mockResolvedValue({ status: TransactionStatus.Included } as TransactionDetail);
.mockResolvedValue({ status: TransactionStatus.Included } as TransactionDetails);

const response = await controller.getTransactionStatus(transactionHash);
expect(response).toEqual({
Expand All @@ -73,7 +73,7 @@ describe("TransactionController", () => {
it("returns isError as 1 when transaction is failed", async () => {
jest
.spyOn(transactionServiceMock, "findOne")
.mockResolvedValue({ status: TransactionStatus.Failed } as TransactionDetail);
.mockResolvedValue({ status: TransactionStatus.Failed } as TransactionDetails);

const response = await controller.getTransactionStatus(transactionHash);
expect(response).toEqual({
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/block/block.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PagingOptionsDto, ListFiltersDto } from "../common/dtos";
import { ApiListPageOkResponse } from "../common/decorators/apiListPageOkResponse";
import { BlockService } from "./block.service";
import { BlockDto } from "./block.dto";
import { BlockDetailDto } from "./blockDetail.dto";
import { BlockDetailsDto } from "./blockDetails.dto";
import { swagger } from "../config/featureFlags";

const entityName = "blocks";
Expand Down Expand Up @@ -48,12 +48,12 @@ export class BlockController {
example: "1",
description: "Block number",
})
@ApiOkResponse({ description: "Block was returned successfully", type: BlockDetailDto })
@ApiOkResponse({ description: "Block was returned successfully", type: BlockDetailsDto })
@ApiBadRequestResponse({ description: "Block number is invalid" })
@ApiNotFoundResponse({ description: "Block with the specified number does not exist" })
public async getBlock(
@Param("blockNumber", new ParseLimitedIntPipe({ min: 0 })) blockNumber: number
): Promise<BlockDetailDto> {
): Promise<BlockDetailsDto> {
const block = await this.blockService.findOne(blockNumber);
if (!block) {
throw new NotFoundException();
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/block/block.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { TypeOrmModule } from "@nestjs/typeorm";
import { BlockService } from "../block/block.service";
import { BlockController } from "./block.controller";
import { Block } from "./block.entity";
import { BlockDetail } from "./blockDetail.entity";
import { BlockDetails } from "./blockDetails.entity";

@Module({
imports: [TypeOrmModule.forFeature([Block, BlockDetail])],
imports: [TypeOrmModule.forFeature([Block, BlockDetails])],
controllers: [BlockController],
providers: [BlockService],
exports: [BlockService],
Expand Down
10 changes: 5 additions & 5 deletions packages/api/src/block/block.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { Pagination, IPaginationMeta } from "nestjs-typeorm-paginate";
import * as utils from "../common/utils";
import { BlockService, FindManyOptions } from "./block.service";
import { Block } from "./block.entity";
import { BlockDetail } from "./blockDetail.entity";
import { BlockDetails } from "./blockDetails.entity";

jest.mock("../common/utils");

describe("BlockService", () => {
let blockRecord;
let service: BlockService;
let repositoryMock: Repository<Block>;
let blockDetailRepositoryMock: Repository<BlockDetail>;
let blockDetailRepositoryMock: Repository<BlockDetails>;

beforeEach(async () => {
repositoryMock = mock<Repository<Block>>();
blockDetailRepositoryMock = mock<Repository<BlockDetail>>();
blockDetailRepositoryMock = mock<Repository<BlockDetails>>();

blockRecord = {
number: 123,
Expand All @@ -32,7 +32,7 @@ describe("BlockService", () => {
useValue: repositoryMock,
},
{
provide: getRepositoryToken(BlockDetail),
provide: getRepositoryToken(BlockDetails),
useValue: blockDetailRepositoryMock,
},
],
Expand Down Expand Up @@ -305,7 +305,7 @@ describe("BlockService", () => {
let filterOptions: FindManyOptions;

beforeEach(() => {
queryBuilderMock = mock<SelectQueryBuilder<BlockDetail>>({
queryBuilderMock = mock<SelectQueryBuilder<BlockDetails>>({
getMany: jest.fn().mockResolvedValue([
{
number: 1,
Expand Down
16 changes: 8 additions & 8 deletions packages/api/src/block/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { Pagination } from "nestjs-typeorm-paginate";
import { paginate } from "../common/utils";
import { IPaginationOptions } from "../common/types";
import { Block } from "./block.entity";
import { BlockDetail } from "./blockDetail.entity";
import { BlockDetails } from "./blockDetails.entity";

export interface FindManyOptions {
miner?: string;
page?: number;
offset?: number;
selectFields?: (keyof BlockDetail)[];
selectFields?: (keyof BlockDetails)[];
}

@Injectable()
export class BlockService {
public constructor(
@InjectRepository(Block)
private readonly blocksRepository: Repository<Block>,
@InjectRepository(BlockDetail)
private readonly blockDetailsRepository: Repository<BlockDetail>
@InjectRepository(BlockDetails)
private readonly blockDetailsRepository: Repository<BlockDetails>
) {}

private getBlock(filterOptions: FindOptionsWhere<Block>, orderOptions: FindOptionsOrder<Block>): Promise<Block> {
Expand Down Expand Up @@ -50,9 +50,9 @@ export class BlockService {

public async findOne(
number: number,
selectFields?: (keyof BlockDetail)[],
relations: FindOptionsRelations<BlockDetail> = { batch: true }
): Promise<BlockDetail> {
selectFields?: (keyof BlockDetails)[],
relations: FindOptionsRelations<BlockDetails> = { batch: true }
): Promise<BlockDetails> {
return await this.blockDetailsRepository.findOne({
where: { number },
relations: relations,
Expand Down Expand Up @@ -90,7 +90,7 @@ export class BlockService {
return await paginate<Block>(queryBuilder, paginationOptions, () => this.count(filterOptions));
}

public async findMany({ miner, page = 1, offset = 10, selectFields }: FindManyOptions): Promise<BlockDetail[]> {
public async findMany({ miner, page = 1, offset = 10, selectFields }: FindManyOptions): Promise<BlockDetails[]> {
const queryBuilder = this.blockDetailsRepository.createQueryBuilder("block");
queryBuilder.addSelect(selectFields);
if (miner) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from "@nestjs/swagger";
import { BlockDto } from "./block.dto";

export class BlockDetailDto extends BlockDto {
export class BlockDetailsDto extends BlockDto {
@ApiProperty({
type: String,
description: "The hash of the previous block",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Block } from "./block.entity";
import { hexTransformer } from "../common/transformers/hex.transformer";

@Entity({ name: "blocks" })
export class BlockDetail extends Block {
export class BlockDetails extends Block {
@Column({ type: "bytea", transformer: hexTransformer, nullable: true })
public readonly parentHash?: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from "@nestjs/swagger";
import { TransactionDto } from "./transaction.dto";

export class TransactionDetailDto extends TransactionDto {
export class TransactionDetailsDto extends TransactionDto {
@ApiProperty({
type: String,
description: "Gas used by the transaction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Entity } from "typeorm";
import { Transaction } from "./transaction.entity";

@Entity({ name: "transactions" })
export class TransactionDetail extends Transaction {
export class TransactionDetails extends Transaction {
public get gasUsed(): string {
return this.transactionReceipt ? this.transactionReceipt.gasUsed : null;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/transaction/transaction.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { buildDateFilter } from "../common/utils";
import { FilterTransactionsOptionsDto } from "./dtos/filterTransactionsOptions.dto";
import { TransferDto } from "../transfer/transfer.dto";
import { TransactionDto } from "./dtos/transaction.dto";
import { TransactionDetailDto } from "./dtos/transactionDetail.dto";
import { TransactionDetailsDto } from "./dtos/transactionDetails.dto";
import { TransferService } from "../transfer/transfer.service";
import { LogDto } from "../log/log.dto";
import { LogService } from "../log/log.service";
Expand Down Expand Up @@ -73,7 +73,7 @@ export class TransactionController {
@ApiNotFoundResponse({ description: "Transaction with the specified hash does not exist" })
public async getTransaction(
@Param("transactionHash", new ParseTransactionHashPipe()) transactionHash: string
): Promise<TransactionDetailDto> {
): Promise<TransactionDetailsDto> {
const transactionDetail = await this.transactionService.findOne(transactionHash);
if (!transactionDetail) {
throw new NotFoundException();
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/transaction/transaction.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TransactionController } from "./transaction.controller";
import { TransactionService } from "./transaction.service";
import { TransactionReceiptService } from "./transactionReceipt.service";
import { Transaction } from "./entities/transaction.entity";
import { TransactionDetail } from "./entities/transactionDetail.entity";
import { TransactionDetails } from "./entities/transactionDetails.entity";
import { AddressTransaction } from "./entities/addressTransaction.entity";
import { TransactionReceipt } from "./entities/transactionReceipt.entity";
import { Batch } from "../batch/batch.entity";
Expand All @@ -14,7 +14,7 @@ import { LogModule } from "../log/log.module";

@Module({
imports: [
TypeOrmModule.forFeature([Transaction, TransactionDetail, AddressTransaction, TransactionReceipt, Batch]),
TypeOrmModule.forFeature([Transaction, TransactionDetails, AddressTransaction, TransactionReceipt, Batch]),
TransferModule,
LogModule,
CounterModule,
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/transaction/transaction.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SortingOrder } from "../common/types";
import { CounterService } from "../counter/counter.service";
import { TransactionService, FilterTransactionsOptions } from "./transaction.service";
import { Transaction } from "./entities/transaction.entity";
import { TransactionDetail } from "./entities/transactionDetail.entity";
import { TransactionDetails } from "./entities/transactionDetails.entity";
import { AddressTransaction } from "./entities/addressTransaction.entity";
import { Batch } from "../batch/batch.entity";

Expand All @@ -18,7 +18,7 @@ describe("TransactionService", () => {
let transaction;
let service: TransactionService;
let repositoryMock: typeorm.Repository<Transaction>;
let repositoryDetailMock: typeorm.Repository<TransactionDetail>;
let repositoryDetailMock: typeorm.Repository<TransactionDetails>;
let addressTransactionRepositoryMock: typeorm.Repository<AddressTransaction>;
let batchRepositoryMock: typeorm.Repository<Batch>;
let counterServiceMock: CounterService;
Expand All @@ -27,7 +27,7 @@ describe("TransactionService", () => {
beforeEach(async () => {
counterServiceMock = mock<CounterService>();
repositoryMock = mock<typeorm.Repository<Transaction>>();
repositoryDetailMock = mock<typeorm.Repository<TransactionDetail>>();
repositoryDetailMock = mock<typeorm.Repository<TransactionDetails>>();
addressTransactionRepositoryMock = mock<typeorm.Repository<AddressTransaction>>();
batchRepositoryMock = mock<typeorm.Repository<Batch>>();
transaction = {
Expand All @@ -42,7 +42,7 @@ describe("TransactionService", () => {
useValue: repositoryMock,
},
{
provide: getRepositoryToken(TransactionDetail),
provide: getRepositoryToken(TransactionDetails),
useValue: repositoryDetailMock,
},
{
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/transaction/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Pagination } from "nestjs-typeorm-paginate";
import { paginate } from "../common/utils";
import { IPaginationOptions, CounterCriteria, SortingOrder } from "../common/types";
import { Transaction } from "./entities/transaction.entity";
import { TransactionDetail } from "./entities/transactionDetail.entity";
import { TransactionDetails } from "./entities/transactionDetails.entity";
import { AddressTransaction } from "./entities/addressTransaction.entity";
import { Batch } from "../batch/batch.entity";
import { CounterService } from "../counter/counter.service";
Expand All @@ -30,16 +30,16 @@ export class TransactionService {
constructor(
@InjectRepository(Transaction)
private readonly transactionRepository: Repository<Transaction>,
@InjectRepository(TransactionDetail)
private readonly transactionDetailsRepository: Repository<TransactionDetail>,
@InjectRepository(TransactionDetails)
private readonly transactionDetailsRepository: Repository<TransactionDetails>,
@InjectRepository(AddressTransaction)
private readonly addressTransactionRepository: Repository<AddressTransaction>,
@InjectRepository(Batch)
private readonly batchRepository: Repository<Batch>,
private readonly counterService: CounterService
) {}

public async findOne(hash: string): Promise<TransactionDetail> {
public async findOne(hash: string): Promise<TransactionDetails> {
const queryBuilder = this.transactionDetailsRepository.createQueryBuilder("transaction");
queryBuilder.leftJoinAndSelect("transaction.batch", "batch");
queryBuilder.leftJoin("transaction.transactionReceipt", "transactionReceipt");
Expand Down
6 changes: 3 additions & 3 deletions packages/api/test/account-api.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getRepositoryToken } from "@nestjs/typeorm";
import * as request from "supertest";
import { Repository } from "typeorm";
import { BatchDetails } from "../src/batch/batchDetails.entity";
import { BlockDetail } from "../src/block/blockDetail.entity";
import { BlockDetails } from "../src/block/blockDetails.entity";
import { AddressTransaction } from "../src/transaction/entities/addressTransaction.entity";
import { Transaction } from "../src/transaction/entities/transaction.entity";
import { TransactionReceipt } from "../src/transaction/entities/transactionReceipt.entity";
Expand All @@ -23,7 +23,7 @@ describe("Account API (e2e)", () => {
let addressTransferRepository: Repository<AddressTransfer>;
let transferRepository: Repository<Transfer>;
let transactionReceiptRepository: Repository<TransactionReceipt>;
let blockRepository: Repository<BlockDetail>;
let blockRepository: Repository<BlockDetails>;
let batchRepository: Repository<BatchDetails>;
let tokenRepository: Repository<Token>;
let balanceRepository: Repository<Balance>;
Expand All @@ -42,7 +42,7 @@ describe("Account API (e2e)", () => {
addressTransferRepository = app.get<Repository<AddressTransfer>>(getRepositoryToken(AddressTransfer));
transferRepository = app.get<Repository<Transfer>>(getRepositoryToken(Transfer));
transactionReceiptRepository = app.get<Repository<TransactionReceipt>>(getRepositoryToken(TransactionReceipt));
blockRepository = app.get<Repository<BlockDetail>>(getRepositoryToken(BlockDetail));
blockRepository = app.get<Repository<BlockDetails>>(getRepositoryToken(BlockDetails));
batchRepository = app.get<Repository<BatchDetails>>(getRepositoryToken(BatchDetails));
tokenRepository = app.get<Repository<Token>>(getRepositoryToken(Token));
balanceRepository = app.get<Repository<Balance>>(getRepositoryToken(Balance));
Expand Down
6 changes: 3 additions & 3 deletions packages/api/test/address.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AppModule } from "../src/app.module";
import { configureApp } from "../src/configureApp";
import { Address } from "../src/address/address.entity";
import { Balance } from "../src/balance/balance.entity";
import { BlockDetail } from "../src/block/blockDetail.entity";
import { BlockDetails } from "../src/block/blockDetails.entity";
import { Transaction } from "../src/transaction/entities/transaction.entity";
import { AddressTransaction } from "../src/transaction/entities/addressTransaction.entity";
import { TransactionReceipt } from "../src/transaction/entities/transactionReceipt.entity";
Expand All @@ -21,7 +21,7 @@ import { AddressTransfer } from "../src/transfer/addressTransfer.entity";
describe("AddressController (e2e)", () => {
let app: INestApplication;
let addressRepository: Repository<Address>;
let blockRepository: Repository<BlockDetail>;
let blockRepository: Repository<BlockDetails>;
let transactionRepository: Repository<Transaction>;
let addressTransactionRepository: Repository<AddressTransaction>;
let transactionReceiptRepository: Repository<TransactionReceipt>;
Expand All @@ -45,7 +45,7 @@ describe("AddressController (e2e)", () => {
await app.init();

addressRepository = app.get<Repository<Address>>(getRepositoryToken(Address));
blockRepository = app.get<Repository<BlockDetail>>(getRepositoryToken(BlockDetail));
blockRepository = app.get<Repository<BlockDetails>>(getRepositoryToken(BlockDetails));
transactionRepository = app.get<Repository<Transaction>>(getRepositoryToken(Transaction));
addressTransactionRepository = app.get<Repository<AddressTransaction>>(getRepositoryToken(AddressTransaction));
transactionReceiptRepository = app.get<Repository<TransactionReceipt>>(getRepositoryToken(TransactionReceipt));
Expand Down
6 changes: 3 additions & 3 deletions packages/api/test/block-api.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { Repository } from "typeorm";
import { getRepositoryToken } from "@nestjs/typeorm";
import { AppModule } from "../src/app.module";
import { configureApp } from "../src/configureApp";
import { BlockDetail } from "../src/block/blockDetail.entity";
import { BlockDetails } from "../src/block/blockDetails.entity";
import { BatchDetails } from "../src/batch/batchDetails.entity";

describe("Block API (e2e)", () => {
let app: INestApplication;
let blockRepository: Repository<BlockDetail>;
let blockRepository: Repository<BlockDetails>;
let batchRepository: Repository<BatchDetails>;

beforeAll(async () => {
Expand All @@ -24,7 +24,7 @@ describe("Block API (e2e)", () => {

await app.init();

blockRepository = app.get<Repository<BlockDetail>>(getRepositoryToken(BlockDetail));
blockRepository = app.get<Repository<BlockDetails>>(getRepositoryToken(BlockDetails));
batchRepository = app.get<Repository<BatchDetails>>(getRepositoryToken(BatchDetails));

for (let i = 0; i < 9; i++) {
Expand Down
Loading

0 comments on commit 3ef5a3e

Please sign in to comment.