Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add round filter for transactions / transfers #1365

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/common/indexer/elastic/elastic.indexer.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ export class ElasticIndexerHelper {
]));
}

if (filter.round) {
elasticQuery = elasticQuery.withMustMatchCondition('round', filter.round);
}

return elasticQuery;
}

Expand Down Expand Up @@ -530,6 +534,10 @@ export class ElasticIndexerHelper {
elasticQuery = elasticQuery.withMustMatchCondition('isRelayed', filter.isRelayed);
}

if (filter.round) {
elasticQuery = elasticQuery.withMustMatchCondition('round', filter.round);
}

if (filter.condition === QueryConditionOptions.should) {
if (filter.sender) {
elasticQuery = elasticQuery.withShouldCondition(QueryType.Match('sender', filter.sender));
Expand Down
14 changes: 14 additions & 0 deletions src/endpoints/accounts/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ export class AccountController {
@ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: 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 })
@ApiQuery({ name: 'withScResults', description: 'Return scResults for transactions. When "withScresults" parameter is applied, complexity estimation is 200', required: false })
@ApiQuery({ name: 'withOperations', description: 'Return operations for transactions. When "withOperations" parameter is applied, complexity estimation is 200', required: false })
@ApiQuery({ name: 'withLogs', description: 'Return logs for transactions. When "withLogs" parameter is applied, complexity estimation is 200', required: false })
Expand All @@ -877,6 +878,7 @@ export class AccountController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('order', new ParseEnumPipe(SortOrder)) order?: SortOrder,
@Query('fields', ParseArrayPipe) fields?: string[],
@Query('withScResults', new ParseBoolPipe) withScResults?: boolean,
Expand Down Expand Up @@ -906,6 +908,7 @@ export class AccountController {
order,
senderOrReceiver,
isRelayed,
round,
}), new QueryPagination({ from, size }), options, address, fields);
}

Expand All @@ -923,6 +926,7 @@ export class AccountController {
@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: 'round', description: 'Round number', required: false })
@ApiQuery({ name: 'senderOrReceiver', description: 'One address that current address interacted with', required: false })
@ApiQuery({ name: 'isRelayed', description: 'Returns isRelayed transactions details', required: false, type: Boolean })
async getAccountTransactionsCount(
Expand All @@ -938,6 +942,7 @@ export class AccountController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
@Query('isRelayed', new ParseBoolPipe) isRelayed?: boolean,
): Promise<number> {
Expand All @@ -956,6 +961,7 @@ export class AccountController {
after,
senderOrReceiver,
isRelayed,
round,
}), address);
}

Expand All @@ -977,6 +983,7 @@ export class AccountController {
@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: 'round', description: 'Round number', required: false })
@ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false })
@ApiQuery({ name: 'relayer', description: 'Address of the relayer', required: false })
@ApiQuery({ name: 'withScamInfo', description: 'Returns scam information', required: false, type: Boolean })
Expand All @@ -1001,6 +1008,7 @@ export class AccountController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('fields', ParseArrayPipe) fields?: string[],
@Query('order', new ParseEnumPipe(SortOrder)) order?: SortOrder,
@Query('relayer', ParseAddressPipe) relayer?: string,
Expand Down Expand Up @@ -1031,6 +1039,7 @@ export class AccountController {
order,
senderOrReceiver,
relayer,
round,
}),
new QueryPagination({ from, size }),
options,
Expand All @@ -1052,6 +1061,7 @@ export class AccountController {
@ApiQuery({ name: 'function', description: 'Filter transfers by function name', required: 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 })
@ApiQuery({ name: 'senderOrReceiver', description: 'One address that current address interacted with', required: false })
async getAccountTransfersCount(
@Param('address', ParseAddressPipe) address: string,
Expand All @@ -1066,6 +1076,7 @@ export class AccountController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
): Promise<number> {
return await this.transferService.getTransfersCount(new TransactionFilter({
Expand All @@ -1082,6 +1093,7 @@ export class AccountController {
before,
after,
senderOrReceiver,
round,
}));
}

Expand All @@ -1100,6 +1112,7 @@ export class AccountController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
): Promise<number> {
return await this.transferService.getTransfersCount(new TransactionFilter({
Expand All @@ -1116,6 +1129,7 @@ export class AccountController {
before,
after,
senderOrReceiver,
round,
}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/accounts/entities/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class Account {
ownerAssets: AccountAssets | undefined = undefined;

@Field(() => Boolean, { description: 'If the given detailed account is verified.', nullable: true })
@ApiProperty({ description: 'Specific property flag for smart contract', type: Boolean })
@ApiProperty({ description: 'Specific property flag for smart contract', type: Boolean, required: false })
isVerified?: boolean;

@Field(() => Float, { description: 'Transactions count for the given detailed account.' })
Expand Down
12 changes: 12 additions & 0 deletions src/endpoints/collections/collection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export class CollectionController {
@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: 'round', description: 'Filter by round number', 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 })
Expand All @@ -349,6 +350,7 @@ export class CollectionController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('order', new ParseEnumPipe(SortOrder)) order?: SortOrder,
@Query('withScResults', new ParseBoolPipe) withScResults?: boolean,
@Query('withOperations', new ParseBoolPipe) withOperations?: boolean,
Expand Down Expand Up @@ -376,6 +378,7 @@ export class CollectionController {
before,
after,
order,
round,
}), new QueryPagination({ from, size }), options);
}

Expand All @@ -392,6 +395,7 @@ export class CollectionController {
@ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus })
@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 })
async getCollectionTransactionsCount(
@Param('collection', ParseCollectionPipe) identifier: string,
@Query('sender', ParseAddressPipe) sender?: string,
Expand All @@ -403,6 +407,7 @@ export class CollectionController {
@Query('status', new ParseEnumPipe(TransactionStatus)) status?: TransactionStatus,
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
) {
const isCollection = await this.collectionService.isCollection(identifier);
if (!isCollection) {
Expand All @@ -420,6 +425,7 @@ export class CollectionController {
status,
before,
after,
round,
}));
}

Expand All @@ -438,6 +444,7 @@ export class CollectionController {
@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: 'round', description: 'Filter by round number', 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 })
Expand All @@ -460,6 +467,7 @@ export class CollectionController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('order', new ParseEnumPipe(SortOrder)) order?: SortOrder,
@Query('withScResults', new ParseBoolPipe) withScResults?: boolean,
@Query('withOperations', new ParseBoolPipe) withOperations?: boolean,
Expand Down Expand Up @@ -487,6 +495,7 @@ export class CollectionController {
before,
after,
order,
round,
}), new QueryPagination({ from, size }), options);
}

Expand All @@ -504,6 +513,7 @@ export class CollectionController {
@ApiQuery({ name: 'function', description: 'Filter transfers by function name', required: false })
@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 })
async getCollectionTransfersCount(
@Param('collection', ParseCollectionPipe) identifier: string,
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
Expand All @@ -516,6 +526,7 @@ export class CollectionController {
@Query('status', new ParseEnumPipe(TransactionStatus)) status?: TransactionStatus,
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
) {
const isCollection = await this.collectionService.isCollection(identifier);
if (!isCollection) {
Expand All @@ -534,6 +545,7 @@ export class CollectionController {
before,
after,
functions,
round,
}));
}

Expand Down
14 changes: 14 additions & 0 deletions src/endpoints/tokens/token.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class TokenController {
@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: 'round', description: 'Filter by round number', 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 })
Expand All @@ -232,6 +233,7 @@ export class TokenController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('order', new ParseEnumPipe(SortOrder)) order?: SortOrder,
@Query('fields', ParseArrayPipe) fields?: string[],
@Query('withScResults', new ParseBoolPipe) withScResults?: boolean,
Expand Down Expand Up @@ -262,6 +264,7 @@ export class TokenController {
before,
after,
order,
round,
}),
new QueryPagination({ from, size }),
options,
Expand All @@ -283,6 +286,7 @@ export class TokenController {
@ApiQuery({ name: 'status', description: 'Status of the transaction (success / pending / invalid / fail)', required: false, enum: TransactionStatus })
@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 })
async getTokenTransactionsCount(
@Param('identifier', ParseTokenPipe) identifier: string,
@Query('sender', ParseAddressPipe) sender?: string,
Expand All @@ -294,6 +298,7 @@ export class TokenController {
@Query('status', new ParseEnumPipe(TransactionStatus)) status?: TransactionStatus,
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
) {
const isToken = await this.tokenService.isToken(identifier);
if (!isToken) {
Expand All @@ -311,6 +316,7 @@ export class TokenController {
status,
before,
after,
round,
}));
}

Expand Down Expand Up @@ -372,6 +378,7 @@ export class TokenController {
@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: 'round', description: 'Filter by round number', required: false })
@ApiQuery({ name: 'fields', description: 'List of fields to filter by', 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 })
Expand All @@ -391,6 +398,7 @@ export class TokenController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
@Query('fields', ParseArrayPipe) fields?: string[],
@Query('order', new ParseEnumPipe(SortOrder)) order?: SortOrder,
@Query('withScamInfo', new ParseBoolPipe) withScamInfo?: boolean,
Expand Down Expand Up @@ -418,6 +426,7 @@ export class TokenController {
before,
after,
order,
round,
}),
new QueryPagination({ from, size }),
options,
Expand All @@ -438,6 +447,7 @@ export class TokenController {
@ApiQuery({ name: 'function', description: 'Filter transfers by function name', required: false })
@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 })
async getTokenTransfersCount(
@Param('identifier', ParseTokenPipe) identifier: string,
@Query('sender', ParseAddressArrayPipe) sender?: string[],
Expand All @@ -450,6 +460,7 @@ export class TokenController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
): Promise<number> {
const isToken = await this.tokenService.isToken(identifier);
if (!isToken) {
Expand All @@ -468,6 +479,7 @@ export class TokenController {
status,
before,
after,
round,
}));
}

Expand All @@ -485,6 +497,7 @@ export class TokenController {
@Query('function', new ParseArrayPipe(new ParseArrayPipeOptions({ allowEmptyString: true }))) functions?: string[],
@Query('before', ParseIntPipe) before?: number,
@Query('after', ParseIntPipe) after?: number,
@Query('round', ParseIntPipe) round?: number,
): Promise<number> {
const isToken = await this.tokenService.isToken(identifier);
if (!isToken) {
Expand All @@ -503,6 +516,7 @@ export class TokenController {
status,
before,
after,
round,
}));
}

Expand Down
1 change: 1 addition & 0 deletions src/endpoints/transactions/entities/transaction.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export class TransactionFilter {
senderOrReceiver?: string;
isRelayed?: boolean;
relayer?: string;
round?: number;
}
Loading
Loading