diff --git a/src/common/entities/sort.nodes.ts b/src/common/entities/sort.nodes.ts new file mode 100644 index 000000000..d28fae1b1 --- /dev/null +++ b/src/common/entities/sort.nodes.ts @@ -0,0 +1,11 @@ +export enum SortNodes { + name = 'name', + version = 'version', + tempRating = 'tempRating', + leaderSuccess = 'leaderSuccess', + leaderFailure = 'leaderFailure', + validatorSuccess = 'validatorSuccess', + validatorFailure = 'validatorFailure', + validatorIgnoredSignatures = 'validatorIgnoredSignatures', + position = 'position', +} diff --git a/src/common/entities/sort.tokens.ts b/src/common/entities/sort.tokens.ts new file mode 100644 index 000000000..0ae158fe8 --- /dev/null +++ b/src/common/entities/sort.tokens.ts @@ -0,0 +1,6 @@ +export enum SortTokens { + accounts = 'accounts', + transactions = 'transactions', + price = 'price', + marketCap = 'marketCap', +} diff --git a/src/endpoints/accounts/account.controller.ts b/src/endpoints/accounts/account.controller.ts index 5924a0559..123a35ed7 100644 --- a/src/endpoints/accounts/account.controller.ts +++ b/src/endpoints/accounts/account.controller.ts @@ -513,7 +513,7 @@ export class AccountController { } @Get("/accounts/:address/transactions") - @ApiOperation({ summary: 'Account transactions details', description: 'Returns details of all transactions where the account is sender or receiver' }) + @ApiOperation({ summary: 'Account transaction list', description: 'Returns details of all transactions where the account is sender or receiver' }) @ApiOkResponse({ type: [Transaction] }) @ApiQuery({ name: 'from', description: 'Number of items to skip for the result set', required: false }) @ApiQuery({ name: 'size', description: 'Number of items to retrieve', required: false }) @@ -524,9 +524,9 @@ export class AccountController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transaction hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) - @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false }) + @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) @ApiQuery({ name: 'withScResults', description: 'Return scResults for transactions', required: false }) @@ -588,7 +588,7 @@ export class AccountController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transaction hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) @ApiQuery({ name: 'function', description: 'Filter transactions by function name', required: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @@ -637,9 +637,9 @@ export class AccountController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transfer hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transfer (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) - @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false }) + @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) async getAccountTransfers( @@ -689,7 +689,7 @@ export class AccountController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transfer hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transfer (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) @ApiQuery({ name: 'function', description: 'Filter transfers by function name', required: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) diff --git a/src/endpoints/collections/collection.controller.ts b/src/endpoints/collections/collection.controller.ts index f35fd2c48..46238c654 100644 --- a/src/endpoints/collections/collection.controller.ts +++ b/src/endpoints/collections/collection.controller.ts @@ -141,21 +141,19 @@ export class CollectionController { @ApiQuery({ name: 'size', description: 'Number of items to retrieve', required: false }) @ApiQuery({ name: 'search', description: 'Search by collection identifier', required: false }) @ApiQuery({ name: 'identifiers', description: 'Search by token identifiers, comma-separated', required: false }) - @ApiQuery({ name: 'type', description: 'Filter by type (NonFungibleESDT/SemiFungibleESDT/MetaESDT)', required: false }) @ApiQuery({ name: 'name', description: 'Get all nfts by name', required: false }) @ApiQuery({ name: 'tags', description: 'Filter by one or more comma-separated tags', required: false }) @ApiQuery({ name: 'creator', description: 'Return all NFTs associated with a given creator', required: false }) - @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false }) - @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false }) - @ApiQuery({ name: 'withOwner', description: 'Return owner where type = NonFungibleESDT', required: false }) - @ApiQuery({ name: 'withSupply', description: 'Return supply where type = SemiFungibleESDT', required: false }) + @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false, type: Boolean }) + @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false, type: Boolean }) + @ApiQuery({ name: 'withOwner', description: 'Return owner where type = NonFungibleESDT', required: false, type: Boolean }) + @ApiQuery({ name: 'withSupply', description: 'Return supply where type = SemiFungibleESDT', required: false, type: Boolean }) async getNfts( @Param('collection') collection: string, @Query('from', new DefaultValuePipe(0), ParseIntPipe) from: number, @Query('size', new DefaultValuePipe(25), ParseIntPipe) size: number, @Query('search') search: string | undefined, @Query('identifiers', ParseArrayPipe) identifiers: string[] | undefined, - @Query('type') type: NftType | undefined, @Query('name') name: string | undefined, @Query('tags', ParseArrayPipe) tags: string[] | undefined, @Query('creator', ParseAddressPipe) creator: string | undefined, @@ -168,7 +166,7 @@ export class CollectionController { throw new BadRequestException(`Maximum size of 100 is allowed when activating flags 'withOwner' or 'withSupply'`); } - return await this.nftService.getNfts({ from, size }, { search, identifiers, type, collection, name, tags, creator, hasUris, isWhitelistedStorage }, { withOwner, withSupply }); + return await this.nftService.getNfts({ from, size }, { search, identifiers, collection, name, tags, creator, hasUris, isWhitelistedStorage }, { withOwner, withSupply }); } @Get("/collections/:collection/nfts/count") @@ -176,23 +174,21 @@ export class CollectionController { @ApiOkResponse({ type: Number }) @ApiQuery({ name: 'search', description: 'Search by collection identifier', required: false }) @ApiQuery({ name: 'identifiers', description: 'Search by token identifiers, comma-separated', required: false }) - @ApiQuery({ name: 'type', description: 'Filter by type (NonFungibleESDT/SemiFungibleESDT/MetaESDT)', required: false }) @ApiQuery({ name: 'name', description: 'Get all nfts by name', required: false }) @ApiQuery({ name: 'tags', description: 'Filter by one or more comma-separated tags', required: false }) @ApiQuery({ name: 'creator', description: 'Return all NFTs associated with a given creator', required: false }) - @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false }) - @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false }) + @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false, type: Boolean }) + @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false, type: Boolean }) async getNftCount( @Param('collection') collection: string, @Query('search') search: string | undefined, @Query('identifiers', ParseArrayPipe) identifiers: string[] | undefined, - @Query('type') type: NftType | undefined, @Query('name') name: string | undefined, @Query('tags', ParseArrayPipe) tags: string[] | undefined, @Query('creator', ParseAddressPipe) creator: string | undefined, @Query('isWhitelistedStorage', new ParseOptionalBoolPipe) isWhitelistedStorage: boolean | undefined, @Query('hasUris', new ParseOptionalBoolPipe) hasUris: boolean | undefined, ): Promise { - return await this.nftService.getNftCount({ search, identifiers, type, collection, name, tags, creator, isWhitelistedStorage, hasUris }); + return await this.nftService.getNftCount({ search, identifiers, collection, name, tags, creator, isWhitelistedStorage, hasUris }); } } diff --git a/src/endpoints/nfts/nft.controller.ts b/src/endpoints/nfts/nft.controller.ts index 0b043e26e..97a614d96 100644 --- a/src/endpoints/nfts/nft.controller.ts +++ b/src/endpoints/nfts/nft.controller.ts @@ -31,10 +31,10 @@ export class NftController { @ApiQuery({ name: 'name', description: 'Get all nfts by name', required: false }) @ApiQuery({ name: 'tags', description: 'Filter by one or more comma-separated tags', required: false }) @ApiQuery({ name: 'creator', description: 'Return all NFTs associated with a given creator', required: false }) - @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false }) - @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false }) - @ApiQuery({ name: 'withOwner', description: 'Return owner where type = NonFungibleESDT', required: false }) - @ApiQuery({ name: 'withSupply', description: 'Return supply where type = SemiFungibleESDT', required: false }) + @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false, type: Boolean }) + @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false, type: Boolean }) + @ApiQuery({ name: 'withOwner', description: 'Return owner where type = NonFungibleESDT', required: false, type: Boolean }) + @ApiQuery({ name: 'withSupply', description: 'Return supply where type = SemiFungibleESDT', required: false, type: Boolean }) async getNfts( @Query('from', new DefaultValuePipe(0), ParseIntPipe) from: number, @Query('size', new DefaultValuePipe(25), ParseIntPipe) size: number, @@ -67,8 +67,8 @@ export class NftController { @ApiQuery({ name: 'name', description: 'Get all nfts by name', required: false }) @ApiQuery({ name: 'tags', description: 'Filter by one or more comma-separated tags', required: false }) @ApiQuery({ name: 'creator', description: 'Return all NFTs associated with a given creator', required: false }) - @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false }) - @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false }) + @ApiQuery({ name: 'isWhitelistedStorage', description: 'Return all NFTs that are whitelisted in storage', required: false, type: Boolean }) + @ApiQuery({ name: 'hasUris', description: 'Return all NFTs that have one or more uris', required: false, type: Boolean }) async getNftCount( @Query('search') search: string | undefined, @Query('identifiers', ParseArrayPipe) identifiers: string[] | undefined, diff --git a/src/endpoints/nodes/node.controller.ts b/src/endpoints/nodes/node.controller.ts index 153d5889b..d69ddc0a1 100644 --- a/src/endpoints/nodes/node.controller.ts +++ b/src/endpoints/nodes/node.controller.ts @@ -11,6 +11,7 @@ import { SortOrder } from "src/common/entities/sort.order"; import { NodeSort } from "./entities/node.sort"; import { ParseAddressPipe } from "src/utils/pipes/parse.address.pipe"; import { ParseBlsHashPipe } from "src/utils/pipes/parse.bls.hash.pipe"; +import { SortNodes } from "src/common/entities/sort.nodes"; @Controller() @ApiTags('nodes') @@ -31,8 +32,8 @@ export class NodeController { @ApiQuery({ name: 'identity', description: 'Node identity', required: false }) @ApiQuery({ name: 'provider', description: 'Node provider', required: false }) @ApiQuery({ name: 'owner', description: 'Node owner', required: false }) - @ApiQuery({ name: 'sort', description: 'Sorting criteria', required: false }) - @ApiQuery({ name: 'order', description: 'Sorting order (asc / desc)', required: false }) + @ApiQuery({ name: 'sort', description: 'Sorting criteria', required: false, enum: SortNodes }) + @ApiQuery({ name: 'order', description: 'Sorting order (asc / desc)', required: false, enum: SortOrder }) async getNodes( @Query('from', new DefaultValuePipe(0), ParseIntPipe) from: number, @Query('size', new DefaultValuePipe(25), ParseIntPipe) size: number, @@ -70,8 +71,8 @@ export class NodeController { @ApiQuery({ name: 'identity', description: 'Node identity', required: false }) @ApiQuery({ name: 'provider', description: 'Node provider', required: false }) @ApiQuery({ name: 'owner', description: 'Node owner', required: false }) - @ApiQuery({ name: 'sort', description: 'Sorting criteria', required: false }) - @ApiQuery({ name: 'order', description: 'Sorting order (asc / desc)', required: false }) + @ApiQuery({ name: 'sort', description: 'Sorting criteria', required: false, enum: SortNodes }) + @ApiQuery({ name: 'order', description: 'Sorting order (asc / desc)', required: false, enum: SortOrder }) getNodeCount( @Query('search') search: string | undefined, @Query('online', ParseOptionalBoolPipe) online: boolean | undefined, diff --git a/src/endpoints/tokens/token.controller.ts b/src/endpoints/tokens/token.controller.ts index 12e267c5e..90aff9449 100644 --- a/src/endpoints/tokens/token.controller.ts +++ b/src/endpoints/tokens/token.controller.ts @@ -17,6 +17,7 @@ import { EsdtSupply } from "../esdt/entities/esdt.supply"; import { Transaction } from "../transactions/entities/transaction"; import { TokenSupplyResult } from "./entities/token.supply.result"; import { TokenSort } from "./entities/token.sort"; +import { SortTokens } from "src/common/entities/sort.tokens"; @Controller() @@ -36,8 +37,8 @@ export class TokenController { @ApiQuery({ name: 'name', description: 'Search by token name', required: false }) @ApiQuery({ name: 'identifier', description: 'Search by token identifier', required: false }) @ApiQuery({ name: 'identifiers', description: 'Search by multiple token identifiers, comma-separated', required: false }) - @ApiQuery({ name: 'sort', description: 'Sorting criteria', required: false }) - @ApiQuery({ name: 'order', description: 'Sorting order (asc / desc)', required: false }) + @ApiQuery({ name: 'sort', description: 'Sorting criteria', required: false, enum: SortTokens }) + @ApiQuery({ name: 'order', description: 'Sorting order (asc / desc)', required: false, enum: SortOrder }) async getTokens( @Query('from', new DefaultValuePipe(0), ParseIntPipe) from: number, @Query('size', new DefaultValuePipe(25), ParseIntPipe) size: number, @@ -167,17 +168,17 @@ export class TokenController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transaction hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / fail)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) @ApiQuery({ name: 'function', description: 'Filter transactions by function name', required: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) - @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false }) + @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) @ApiQuery({ name: 'from', description: 'Number of items to skip for the result set', required: false }) @ApiQuery({ name: 'size', description: 'Number of items to retrieve', required: false }) - @ApiQuery({ name: 'withScResults', description: 'Return scResults for transactions', required: false }) - @ApiQuery({ name: 'withOperations', description: 'Return operations for transactions', required: false }) - @ApiQuery({ name: 'withLogs', description: 'Return logs for transactions', required: false }) + @ApiQuery({ name: 'withScResults', description: 'Return scResults for transactions', required: false, type: Boolean }) + @ApiQuery({ name: 'withOperations', description: 'Return operations for transactions', required: false, type: Boolean }) + @ApiQuery({ name: 'withLogs', description: 'Return logs for transactions', required: false, type: Boolean }) async getTokenTransactions( @Param('identifier') identifier: string, @Query('sender', ParseAddressPipe) sender: string | undefined, @@ -234,7 +235,7 @@ export class TokenController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transaction hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) diff --git a/src/endpoints/transactions/entities/transaction.status.ts b/src/endpoints/transactions/entities/transaction.status.ts index ff3aabad5..b2dc04cf3 100644 --- a/src/endpoints/transactions/entities/transaction.status.ts +++ b/src/endpoints/transactions/entities/transaction.status.ts @@ -1,5 +1,6 @@ export enum TransactionStatus { success = 'success', pending = 'pending', + invalid = 'invalid', fail = 'fail' } diff --git a/src/endpoints/transactions/transaction.controller.ts b/src/endpoints/transactions/transaction.controller.ts index ab341401c..cda99e0f5 100644 --- a/src/endpoints/transactions/transaction.controller.ts +++ b/src/endpoints/transactions/transaction.controller.ts @@ -35,7 +35,7 @@ export class TransactionController { constructor(private readonly transactionService: TransactionService) { } @Get("/transactions") - @ApiOperation({ summary: 'Transactions details', description: 'Returns a list of transactions available on the blockchain. Maximum size of 50 is allowed when activating flags withScResults, withOperation or withLogs' }) + @ApiOperation({ summary: 'Transaction list', description: 'Returns a list of transactions available on the blockchain. Maximum size of 50 is allowed when activating flags withScResults, withOperation or withLogs' }) @ApiOkResponse({ type: [Transaction] }) @ApiQuery({ name: 'sender', description: 'Address of the transaction sender', required: false }) @ApiQuery({ name: 'receiver', description: 'Address of the transaction receiver', required: false }) @@ -44,18 +44,18 @@ export class TransactionController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transaction hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) @ApiQuery({ name: 'function', description: 'Filter transactions by function name', required: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) - @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false }) + @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) @ApiQuery({ name: 'from', description: 'Number of items to skip for the result set', required: false }) @ApiQuery({ name: 'size', description: 'Number of items to retrieve', required: false }) @ApiQuery({ name: 'condition', description: 'Condition for elastic search queries', required: false, deprecated: true }) - @ApiQuery({ name: 'withScResults', description: 'Return results for transactions', required: false }) - @ApiQuery({ name: 'withOperations', description: 'Return operations for transactions', required: false }) - @ApiQuery({ name: 'withLogs', description: 'Return logs for transactions', required: false }) + @ApiQuery({ name: 'withScResults', description: 'Return results for transactions', required: false, type: Boolean }) + @ApiQuery({ name: 'withOperations', description: 'Return operations for transactions', required: false, type: Boolean }) + @ApiQuery({ name: 'withLogs', description: 'Return logs for transactions', required: false, type: Boolean }) getTransactions( @Query('sender', ParseAddressPipe) sender: string | undefined, @Query('receiver', ParseAddressPipe) receiver: string | undefined, @@ -109,7 +109,7 @@ export class TransactionController { @ApiQuery({ name: 'receiverShard', description: 'Id of the shard the receiver address belongs to', required: false }) @ApiQuery({ name: 'miniBlockHash', description: 'Filter by miniblock hash', required: false }) @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transaction hashes', required: false }) - @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid)', required: false }) + @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'condition', description: 'Condition for elastic search queries', required: false, deprecated: true }) @ApiQuery({ name: 'search', description: 'Search in data object', required: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false })