From 998a6fdc72524f4277735f717154efb7c6ebf708 Mon Sep 17 00:00:00 2001 From: Vasyl Ivanchuk Date: Tue, 31 Oct 2023 09:46:19 +0200 Subject: [PATCH] fix: docs for txlistinternal api endpoint (#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ Improved docs for txlistinternal api endpoint ## Why ❔ It's more user friendly to have separate swagger definitions for txlistinternal endpoint without params, with address and with txHash param. ## Checklist - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [X] Tests for the changes have been added / updated. - [X] Documentation comments have been added / updated. --- packages/api/src/api/api.controller.spec.ts | 14 +++++++++ packages/api/src/api/api.controller.ts | 35 +++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/packages/api/src/api/api.controller.spec.ts b/packages/api/src/api/api.controller.spec.ts index 567eaa2876..d2dad27554 100644 --- a/packages/api/src/api/api.controller.spec.ts +++ b/packages/api/src/api/api.controller.spec.ts @@ -108,6 +108,20 @@ describe("ApiController", () => { }); }); + describe("getInternalTransactions", () => { + it("returns null as it is defined only to appear in docs and cannot be called", async () => { + const result = await controller.getInternalTransactions( + { + page: 1, + offset: 10, + maxLimit: 10000, + }, + { sort: SortingOrder.Desc } + ); + expect(result).toBe(null); + }); + }); + describe("getAccountInternalTransactions", () => { it("returns null as it is defined only to appear in docs and cannot be called", async () => { const result = await controller.getAccountInternalTransactions( diff --git a/packages/api/src/api/api.controller.ts b/packages/api/src/api/api.controller.ts index 7694f04c7d..09891c6463 100644 --- a/packages/api/src/api/api.controller.ts +++ b/packages/api/src/api/api.controller.ts @@ -232,6 +232,37 @@ export class ApiController { return null; } + @ApiTags("Account API") + @Get("api?module=account&action=txlistinternal") + @ApiOperation({ summary: "Retrieve internal transactions" }) + @ApiQuery({ + name: "startblock", + type: "integer", + description: "The block number to start searching for internal transactions", + example: 0, + required: false, + }) + @ApiQuery({ + name: "endblock", + type: "integer", + description: "The block number to stop searching for internal transactions", + example: 99999999, + required: false, + }) + @ApiExtraModels(AccountInternalTransactionDto) + @ApiOkResponse({ + description: "Internal transactions list", + type: AccountInternalTransactionsResponseDto, + }) + public async getInternalTransactions( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Query() pagingOptions: PagingOptionsWithMaxItemsLimitDto, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Query() sortingOptions: SortingOptionsDto + ): Promise { + return null; + } + @ApiTags("Account API") @Get("api?module=account&action=txlistinternal&address=") @ApiOperation({ summary: "Retrieve internal transactions for a given address" }) @@ -239,7 +270,7 @@ export class ApiController { name: "address", description: "The address to filter internal transactions by", example: constants.addressWithInternalTx, - required: false, + required: true, }) @ApiQuery({ name: "startblock", @@ -276,7 +307,7 @@ export class ApiController { name: "txhash", description: "The transaction hash to filter internal transaction by", example: constants.addressTxWithInternalTransfers, - required: false, + required: true, }) @ApiQuery({ name: "startblock",