From 5cf7be060186886e81c63a15cab0a30917dd8099 Mon Sep 17 00:00:00 2001 From: Catalin Faur <52102171+cfaur09@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:48:10 +0200 Subject: [PATCH 1/2] fix fields query in transactions (#1397) * fix fields query in transactions * fix fields ApiQuery properties for the remaining controllers --- src/endpoints/accounts/account.controller.ts | 10 +++++----- src/endpoints/tokens/token.controller.ts | 2 +- src/endpoints/transactions/transaction.controller.ts | 4 ++-- src/endpoints/transfers/transfer.controller.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/endpoints/accounts/account.controller.ts b/src/endpoints/accounts/account.controller.ts index 77bec37c7..9af332110 100644 --- a/src/endpoints/accounts/account.controller.ts +++ b/src/endpoints/accounts/account.controller.ts @@ -191,7 +191,7 @@ export class AccountController { @UseInterceptors(DeepHistoryInterceptor) @ApiOperation({ summary: 'Account details', description: 'Returns account details for a given address' }) @ApiQuery({ name: 'withGuardianInfo', description: 'Returns guardian data for a given address', required: false }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'timestamp', description: 'Retrieve entry from timestamp', required: false, type: Number }) @ApiOkResponse({ type: AccountDetailed }) async getAccountDetails( @@ -615,7 +615,7 @@ export class AccountController { @ApiQuery({ name: 'withScamInfo', description: 'Include scam info in the response', required: false, type: Boolean }) @ApiQuery({ name: 'computeScamInfo', description: 'Compute scam info in the response', required: false, type: Boolean }) @ApiQuery({ name: 'excludeMetaESDT', description: 'Exclude NFTs of type "MetaESDT" in the response', required: false, type: Boolean }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'isScam', description: 'Filter by scam status', required: false, type: Boolean }) @ApiQuery({ name: 'scamType', description: 'Filter by type (scam/potentialScam)', required: false }) @ApiQuery({ name: 'timestamp', description: 'Retrieve entry from timestamp', required: false, type: Number }) @@ -749,7 +749,7 @@ export class AccountController { @Get("/accounts/:address/nfts/:nft") @UseInterceptors(DeepHistoryInterceptor) @ApiOperation({ summary: 'Account NFT/SFT token details', description: 'Returns details about a specific fungible token for a given address' }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'extract', description: 'Extract a specific field', required: false }) @ApiQuery({ name: 'timestamp', description: 'Retrieve entry from timestamp', required: false, type: Number }) @ApiOkResponse({ type: NftAccount }) @@ -851,7 +851,7 @@ export class AccountController { @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'function', description: 'Filter transactions by function name', required: false }) @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) @ApiQuery({ name: 'round', description: 'Round number', required: false }) @@ -986,7 +986,7 @@ export class AccountController { @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) @ApiQuery({ name: 'round', description: 'Round number', required: false }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'relayer', description: 'Address of the relayer', required: false }) @ApiQuery({ name: 'withScamInfo', description: 'Returns scam information', required: false, type: Boolean }) @ApiQuery({ name: 'withUsername', description: 'Integrates username in assets for all addresses present in the transactions', required: false, type: Boolean }) diff --git a/src/endpoints/tokens/token.controller.ts b/src/endpoints/tokens/token.controller.ts index d206e9c16..e3d1e1854 100644 --- a/src/endpoints/tokens/token.controller.ts +++ b/src/endpoints/tokens/token.controller.ts @@ -379,7 +379,7 @@ export class TokenController { @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) @ApiQuery({ name: 'round', description: 'Filter by round number', required: false }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'withScamInfo', description: 'Returns scam information', required: false, type: Boolean }) @ApiQuery({ name: 'withUsername', description: 'Integrates username in assets for all addresses present in the transactions', required: false, type: Boolean }) @ApiQuery({ name: 'withBlockInfo', description: 'Returns sender / receiver block details', required: false, type: Boolean }) diff --git a/src/endpoints/transactions/transaction.controller.ts b/src/endpoints/transactions/transaction.controller.ts index 5342002e8..4e2c415cf 100644 --- a/src/endpoints/transactions/transaction.controller.ts +++ b/src/endpoints/transactions/transaction.controller.ts @@ -37,7 +37,7 @@ export class TransactionController { @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) @ApiQuery({ name: 'round', description: 'Round number', required: false }) @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @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 }) @@ -193,7 +193,7 @@ export class TransactionController { @ApiOperation({ summary: 'Transaction details', description: 'Return transaction details for a given transaction hash' }) @ApiOkResponse({ type: TransactionDetailed }) @ApiNotFoundResponse({ description: 'Transaction not found' }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'withActionTransferValue', description: 'Returns value in USD and EGLD for transferred tokens within the action attribute', required: false }) async getTransaction( @Param('txHash', ParseTransactionHashPipe) txHash: string, diff --git a/src/endpoints/transfers/transfer.controller.ts b/src/endpoints/transfers/transfer.controller.ts index ca2c4622b..117be703e 100644 --- a/src/endpoints/transfers/transfer.controller.ts +++ b/src/endpoints/transfers/transfer.controller.ts @@ -33,7 +33,7 @@ export class TransferController { @ApiQuery({ name: 'hashes', description: 'Filter by a comma-separated list of transfer hashes', required: false }) @ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus }) @ApiQuery({ name: 'order', description: 'Sort order (asc/desc)', required: false, enum: SortOrder }) - @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false }) + @ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false }) @ApiQuery({ name: 'before', description: 'Before timestamp', required: false }) @ApiQuery({ name: 'after', description: 'After timestamp', required: false }) @ApiQuery({ name: 'round', description: 'Round number', required: false }) From 429c41006b3d0243cbb5ab9e548a1f287428f8cb Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Wed, 27 Nov 2024 17:45:34 +0200 Subject: [PATCH 2/2] hotfix --- src/endpoints/tokens/token.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/endpoints/tokens/token.service.ts b/src/endpoints/tokens/token.service.ts index 107f371c5..0f7782fc8 100644 --- a/src/endpoints/tokens/token.service.ts +++ b/src/endpoints/tokens/token.service.ts @@ -431,6 +431,10 @@ export class TokenService { ...esdt, }; + if (esdt.type === '') { // empty type can come from gateway + tokenWithBalance.type = token.type; + } + tokensWithBalance.push(tokenWithBalance); }