Skip to content

Commit

Permalink
fix: docs for txlistinternal api endpoint (#73)
Browse files Browse the repository at this point in the history
# 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

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [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.
  • Loading branch information
vasyl-ivanchuk authored Oct 31, 2023
1 parent e777cf5 commit 998a6fd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/api/src/api/api.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
35 changes: 33 additions & 2 deletions packages/api/src/api/api.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,45 @@ 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<AccountInternalTransactionsResponseDto> {
return null;
}

@ApiTags("Account API")
@Get("api?module=account&action=txlistinternal&address=")
@ApiOperation({ summary: "Retrieve internal transactions for a given address" })
@ApiQuery({
name: "address",
description: "The address to filter internal transactions by",
example: constants.addressWithInternalTx,
required: false,
required: true,
})
@ApiQuery({
name: "startblock",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 998a6fd

Please sign in to comment.