diff --git a/indexers/api/src/controllers/accounts.controller.ts b/indexers/api/src/controllers/accounts.controller.ts index a59d6327..c799301c 100644 --- a/indexers/api/src/controllers/accounts.controller.ts +++ b/indexers/api/src/controllers/accounts.controller.ts @@ -4,7 +4,7 @@ import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Accounts } from '../entities/consensus/accounts.entity'; -@ApiTags('accounts') +@ApiTags('Accounts') @Controller('accounts') export class AccountsController { constructor( @@ -13,7 +13,10 @@ export class AccountsController { ) {} @Get(':accountId') - @ApiOperation({ summary: 'Get account details by ID' }) + @ApiOperation({ + operationId: 'getAccountById', + summary: 'Get account details by ID', + }) @ApiParam({ name: 'accountId', description: 'Account ID or address' }) @ApiResponse({ status: 200, diff --git a/indexers/api/src/controllers/blocks.controller.ts b/indexers/api/src/controllers/blocks.controller.ts index 6f3f8fcf..bf3dac83 100644 --- a/indexers/api/src/controllers/blocks.controller.ts +++ b/indexers/api/src/controllers/blocks.controller.ts @@ -1,25 +1,40 @@ import { Controller, Get, NotFoundException, Param } from '@nestjs/common'; -import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; import { Blocks } from '../entities/consensus/blocks.entity'; import { BlocksService } from '../services/blocks.service'; -@ApiTags('blocks') +@ApiTags('Blocks') @Controller('blocks') export class BlocksController { constructor(private readonly blocksService: BlocksService) {} @Get('latest') - @ApiOperation({ summary: 'Get latest block' }) + @ApiOperation({ + operationId: 'getLatestBlock', + summary: 'Get latest block', + }) @ApiResponse({ status: 200, description: 'Returns the latest block', type: Blocks, }) + @ApiResponse({ status: 404, description: 'No blocks found' }) async getLatestBlock(): Promise { return this.blocksService.findLatest(); } @Get(':height') + @ApiOperation({ + operationId: 'getBlockByHeight', + summary: 'Get block by height', + }) + @ApiParam({ name: 'height', description: 'Block height' }) + @ApiResponse({ + status: 200, + description: 'Returns the block details', + type: Blocks, + }) + @ApiResponse({ status: 404, description: 'Block not found' }) async getBlockByHeight(@Param('height') height: string) { const block = await this.blocksService.findByHeight(Number(height)); diff --git a/indexers/api/src/entities/account.entity.ts b/indexers/api/src/entities/account.entity.ts deleted file mode 100644 index e1994ff3..00000000 --- a/indexers/api/src/entities/account.entity.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity('accounts') -export class Account { - @ApiProperty() - @PrimaryColumn() - id: string; - - @ApiProperty() - @Column({ nullable: true }) - balance: string; - - @ApiProperty() - @Column({ nullable: true }) - nonce: number; - - @ApiProperty() - @Column({ type: 'timestamp', nullable: true }) - lastUpdated: Date; -} diff --git a/indexers/api/src/entities/consensus/accounts.entity.ts b/indexers/api/src/entities/consensus/accounts.entity.ts index 32e5f999..fe7247d5 100644 --- a/indexers/api/src/entities/consensus/accounts.entity.ts +++ b/indexers/api/src/entities/consensus/accounts.entity.ts @@ -1,26 +1,34 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Column, Entity } from 'typeorm'; import { BaseEntity } from './base.entity'; @Entity('accounts', { schema: 'consensus' }) export class Accounts extends BaseEntity { + @ApiProperty() @Column('text') id: string; + @ApiProperty() @Column('numeric') nonce: number; + @ApiProperty() @Column('numeric') free: number; + @ApiProperty() @Column('numeric') reserved: number; + @ApiProperty() @Column('numeric', { nullable: true }) total: number; + @ApiProperty() @Column('numeric') created_at: number; + @ApiProperty() @Column('numeric') updated_at: number; } diff --git a/indexers/api/src/entities/consensus/blocks.entity.ts b/indexers/api/src/entities/consensus/blocks.entity.ts index 43705186..77ecc5f4 100644 --- a/indexers/api/src/entities/consensus/blocks.entity.ts +++ b/indexers/api/src/entities/consensus/blocks.entity.ts @@ -1,71 +1,94 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Column, Entity } from 'typeorm'; import { BaseEntity } from './base.entity'; @Entity('blocks', { schema: 'consensus' }) export class Blocks extends BaseEntity { + @ApiProperty() @Column('text') id: string; + @ApiProperty() @Column('text') sort_id: string; + @ApiProperty() @Column('numeric') height: number; + @ApiProperty() @Column('text') hash: string; + @ApiProperty() @Column('timestamp without time zone') timestamp: Date; + @ApiProperty() @Column('text') parent_hash: string; + @ApiProperty() @Column('text') spec_id: string; + @ApiProperty() @Column('text') state_root: string; + @ApiProperty() @Column('text') extrinsics_root: string; + @ApiProperty() @Column('numeric') space_pledged: number; + @ApiProperty() @Column('numeric') blockchain_size: number; + @ApiProperty() @Column('integer') extrinsics_count: number; + @ApiProperty() @Column('integer') events_count: number; + @ApiProperty() @Column('integer') transfers_count: number; + @ApiProperty() @Column('integer') rewards_count: number; + @ApiProperty() @Column('integer') block_rewards_count: number; + @ApiProperty() @Column('integer') vote_rewards_count: number; + @ApiProperty() @Column('numeric') transfer_value: number; + @ApiProperty() @Column('numeric') reward_value: number; + @ApiProperty() @Column('numeric') block_reward_value: number; + @ApiProperty() @Column('numeric') vote_reward_value: number; + @ApiProperty() @Column('text') author_id: string; } diff --git a/indexers/api/src/entities/consensus/extrinsics.entity.ts b/indexers/api/src/entities/consensus/extrinsics.entity.ts index 02bb9ca6..db90b933 100644 --- a/indexers/api/src/entities/consensus/extrinsics.entity.ts +++ b/indexers/api/src/entities/consensus/extrinsics.entity.ts @@ -1,65 +1,86 @@ +import { ApiProperty } from '@nestjs/swagger'; import { Column, Entity } from 'typeorm'; import { BaseEntity } from './base.entity'; @Entity('extrinsics', { schema: 'consensus' }) export class Extrinsics extends BaseEntity { + @ApiProperty() @Column('text') id: string; + @ApiProperty() @Column('text') sort_id: string; + @ApiProperty() @Column('text') hash: string; + @ApiProperty() @Column('numeric') block_height: number; + @ApiProperty() @Column('text') block_hash: string; + @ApiProperty() @Column('text') section: string; + @ApiProperty() @Column('text') module: string; + @ApiProperty() @Column('text') name: string; + @ApiProperty() @Column('integer') index_in_block: number; + @ApiProperty() @Column('boolean') success: boolean; + @ApiProperty() @Column('timestamp without time zone') timestamp: Date; + @ApiProperty() @Column('numeric') nonce: number; + @ApiProperty() @Column('text') signer: string; + @ApiProperty() @Column('text') signature: string; + @ApiProperty() @Column('text') args: string; + @ApiProperty() @Column('text') error: string; + @ApiProperty() @Column('numeric') tip: number; + @ApiProperty() @Column('numeric') fee: number; + @ApiProperty() @Column('integer') pos: number; + @ApiProperty() @Column('text', { nullable: true }) cid: string; }