Skip to content

Commit 1d757c4

Browse files
Merge pull request #1442 from multiversx/development
Development
2 parents 914e3c9 + a541f0f commit 1d757c4

15 files changed

Lines changed: 156 additions & 12 deletions

src/common/gateway/entities/transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ export class Transaction {
4343
logs: TransactionLog | undefined = undefined;
4444
receipt: TransactionReceipt | undefined = undefined;
4545
smartContractResults: GatewaySmartContractResults[] | undefined = undefined;
46+
relayerAddress: string = '';
47+
relayerSignature: string = '';
4648
}

src/common/gateway/gateway.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class GatewayService {
3131
GatewayComponentRequest.vmQuery,
3232
GatewayComponentRequest.transactionPool,
3333
GatewayComponentRequest.guardianData,
34+
GatewayComponentRequest.validatorAuction,
3435
]);
3536

3637
private readonly deepHistoryRequestsSet: Set<String> = new Set([

src/common/indexer/elastic/elastic.indexer.helper.ts

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,40 @@ export class ElasticIndexerHelper {
316316
if (filter.withRefunds) {
317317
mustNotQueries = [];
318318
}
319+
320+
const shouldConditions = [
321+
QueryType.Match('sender', filter.address),
322+
QueryType.Match('receiver', filter.address),
323+
QueryType.Match('receivers', filter.address),
324+
];
325+
if (filter.withTxsRelayedByAddress) {
326+
shouldConditions.push(QueryType.Match('relayer', filter.address));
327+
}
328+
319329
elasticQuery = elasticQuery.withCondition(QueryConditionOptions.should, QueryType.Must([
320330
QueryType.Match('type', 'unsigned'),
321331
QueryType.Should(smartContractResultConditions),
322332
], mustNotQueries))
323333
.withCondition(QueryConditionOptions.should, QueryType.Must([
324334
QueryType.Should([QueryType.Match('type', 'normal')]),
325-
QueryType.Should([
326-
QueryType.Match('sender', filter.address),
327-
QueryType.Match('receiver', filter.address),
328-
QueryType.Match('receivers', filter.address),
329-
]),
335+
QueryType.Should(shouldConditions),
330336
]));
331337
}
332338

333339
if (filter.relayer) {
334340
elasticQuery = elasticQuery.withMustMatchCondition('relayerAddr', filter.relayer);
335341
}
336342

337-
if (filter.isRelayed) {
338-
elasticQuery = elasticQuery.withMustMatchCondition('isRelayed', filter.isRelayed);
343+
if (filter.isRelayed !== undefined) {
344+
const relayedConditions = QueryType.Should([
345+
QueryType.Match('isRelayed', true),
346+
QueryType.Exists('relayer'),
347+
]);
348+
if (filter.isRelayed === true) {
349+
elasticQuery = elasticQuery.withMustCondition(relayedConditions);
350+
} else if (filter.isRelayed === false) {
351+
elasticQuery = elasticQuery.withMustNotCondition(relayedConditions);
352+
}
339353
}
340354

341355
if (filter.type) {
@@ -410,6 +424,12 @@ export class ElasticIndexerHelper {
410424
elasticQuery = elasticQuery.withMustMatchCondition('round', filter.round);
411425
}
412426

427+
if (filter.isScCall !== undefined) {
428+
elasticQuery = filter.isScCall
429+
? elasticQuery.withMustCondition(QueryType.Match('isScCall', true))
430+
: elasticQuery.withMustNotCondition(QueryType.Match('isScCall', true));
431+
}
432+
413433
return elasticQuery;
414434
}
415435

@@ -549,8 +569,20 @@ export class ElasticIndexerHelper {
549569
elasticQuery = elasticQuery.withMustMatchCondition('tokens', filter.token, QueryOperator.AND);
550570
}
551571

552-
if (filter.isRelayed) {
553-
elasticQuery = elasticQuery.withMustMatchCondition('isRelayed', filter.isRelayed);
572+
if (filter.isRelayed !== undefined) {
573+
const relayedConditions = QueryType.Should([
574+
QueryType.Match('isRelayed', true),
575+
QueryType.Exists('relayer'),
576+
]);
577+
if (filter.isRelayed === true) {
578+
elasticQuery = elasticQuery.withMustCondition(relayedConditions);
579+
} else if (filter.isRelayed === false) {
580+
elasticQuery = elasticQuery.withMustNotCondition(relayedConditions);
581+
}
582+
}
583+
584+
if (filter.relayer) {
585+
elasticQuery = elasticQuery.withShouldCondition(QueryType.Match('relayer', filter.relayer));
554586
}
555587

556588
if (filter.round) {
@@ -603,6 +635,12 @@ export class ElasticIndexerHelper {
603635
]));
604636
}
605637

638+
if (filter.isScCall !== undefined) {
639+
elasticQuery = filter.isScCall
640+
? elasticQuery.withMustCondition(QueryType.Match('isScCall', true))
641+
: elasticQuery.withMustNotCondition(QueryType.Match('isScCall', true));
642+
}
643+
606644
return elasticQuery;
607645
}
608646

src/common/indexer/entities/transaction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ export interface Transaction {
3131
scResults: any[];
3232
version: number;
3333
relayerAddr: string;
34+
relayer: string;
35+
relayerSignature: string;
36+
isRelayed: boolean;
37+
isScCall: boolean;
3438
}

src/endpoints/accounts/account.controller.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export class AccountController {
147147
@ApiQuery({ name: 'isSmartContract', description: 'Return total smart contracts count', required: false })
148148
@ApiQuery({ name: 'name', description: 'Filter accounts by assets name', required: false })
149149
@ApiQuery({ name: 'tags', description: 'Filter accounts by assets tags', required: false })
150+
@ApiQuery({ name: 'search', description: 'Search by account address, assets name', required: false })
150151
@ApiQuery({ name: 'excludeTags', description: 'Exclude specific tags from result', required: false })
151152
@ApiQuery({ name: 'hasAssets', description: 'Returns a list of accounts that have assets', required: false })
152153
async getAccountsCount(
@@ -156,6 +157,7 @@ export class AccountController {
156157
@Query("tags", ParseArrayPipe) tags?: string[],
157158
@Query("excludeTags", ParseArrayPipe) excludeTags?: string[],
158159
@Query("hasAssets", ParseBoolPipe) hasAssets?: boolean,
160+
@Query("search") search?: string,
159161
): Promise<number> {
160162
return await this.accountService.getAccountsCount(
161163
new AccountQueryOptions(
@@ -166,6 +168,7 @@ export class AccountController {
166168
tags,
167169
excludeTags,
168170
hasAssets,
171+
search,
169172
}));
170173
}
171174

@@ -178,6 +181,7 @@ export class AccountController {
178181
@Query("tags", ParseArrayPipe) tags?: string[],
179182
@Query("excludeTags", ParseArrayPipe) excludeTags?: string[],
180183
@Query("hasAssets", ParseBoolPipe) hasAssets?: boolean,
184+
@Query("search") search?: string,
181185
): Promise<number> {
182186
return await this.accountService.getAccountsCount(
183187
new AccountQueryOptions(
@@ -188,6 +192,7 @@ export class AccountController {
188192
tags,
189193
excludeTags,
190194
hasAssets,
195+
search,
191196
}));
192197
}
193198

@@ -877,6 +882,7 @@ export class AccountController {
877882
@ApiQuery({ name: 'computeScamInfo', required: false, type: Boolean })
878883
@ApiQuery({ name: 'senderOrReceiver', description: 'One address that current address interacted with', required: false })
879884
@ApiQuery({ name: 'isRelayed', description: 'Returns isRelayed transactions details', required: false, type: Boolean })
885+
@ApiQuery({ name: 'isScCall', description: 'Returns sc call transactions details', required: false, type: Boolean })
880886
@ApiQuery({ name: 'withActionTransferValue', description: 'Returns value in USD and EGLD for transferred tokens within the action attribute', required: false })
881887
@ApiQuery({ name: 'withRelayedScresults', description: 'If set to true, will include smart contract results that resemble relayed transactions', required: false, type: Boolean })
882888
async getAccountTransactions(
@@ -905,6 +911,7 @@ export class AccountController {
905911
@Query('withBlockInfo', ParseBoolPipe) withBlockInfo?: boolean,
906912
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
907913
@Query('isRelayed', ParseBoolPipe) isRelayed?: boolean,
914+
@Query('isScCall', ParseBoolPipe) isScCall?: boolean,
908915
@Query('withActionTransferValue', ParseBoolPipe) withActionTransferValue?: boolean,
909916
@Query('withRelayedScresults', ParseBoolPipe) withRelayedScresults?: boolean,
910917
) {
@@ -925,6 +932,7 @@ export class AccountController {
925932
order,
926933
senderOrReceiver,
927934
isRelayed,
935+
isScCall,
928936
round,
929937
withRelayedScresults,
930938
});
@@ -949,6 +957,7 @@ export class AccountController {
949957
@ApiQuery({ name: 'round', description: 'Round number', required: false })
950958
@ApiQuery({ name: 'senderOrReceiver', description: 'One address that current address interacted with', required: false })
951959
@ApiQuery({ name: 'isRelayed', description: 'Returns isRelayed transactions details', required: false, type: Boolean })
960+
@ApiQuery({ name: 'isScCall', description: 'Returns sc call transactions details', required: false, type: Boolean })
952961
@ApiQuery({ name: 'withRelayedScresults', description: 'If set to true, will include smart contract results that resemble relayed transactions', required: false, type: Boolean })
953962
async getAccountTransactionsCount(
954963
@Param('address', ParseAddressPipe) address: string,
@@ -966,6 +975,7 @@ export class AccountController {
966975
@Query('round', ParseIntPipe) round?: number,
967976
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
968977
@Query('isRelayed', ParseBoolPipe) isRelayed?: boolean,
978+
@Query('isScCall', ParseBoolPipe) isScCall?: boolean,
969979
@Query('withRelayedScresults', ParseBoolPipe) withRelayedScresults?: boolean,
970980

971981
): Promise<number> {
@@ -984,6 +994,7 @@ export class AccountController {
984994
after,
985995
senderOrReceiver,
986996
isRelayed,
997+
isScCall,
987998
round,
988999
withRelayedScresults,
9891000
}), address);
@@ -1010,6 +1021,7 @@ export class AccountController {
10101021
@ApiQuery({ name: 'round', description: 'Round number', required: false })
10111022
@ApiQuery({ name: 'fields', description: 'List of fields to filter by', required: false, isArray: true, style: 'form', explode: false })
10121023
@ApiQuery({ name: 'relayer', description: 'Address of the relayer', required: false })
1024+
@ApiQuery({ name: 'isScCall', description: 'Returns sc call transactions details', required: false, type: Boolean })
10131025
@ApiQuery({ name: 'withScamInfo', description: 'Returns scam information', required: false, type: Boolean })
10141026
@ApiQuery({ name: 'withUsername', description: 'Integrates username in assets for all addresses present in the transactions', required: false, type: Boolean })
10151027
@ApiQuery({ name: 'withBlockInfo', description: 'Returns sender / receiver block details', required: false, type: Boolean })
@@ -1018,6 +1030,7 @@ export class AccountController {
10181030
@ApiQuery({ name: 'withOperations', description: 'Return operations for transfers. When "withOperations" parameter is applied, complexity estimation is 200', required: false })
10191031
@ApiQuery({ name: 'withActionTransferValue', description: 'Returns value in USD and EGLD for transferred tokens within the action attribute', required: false })
10201032
@ApiQuery({ name: 'withRefunds', description: 'Include refund transactions', required: false })
1033+
@ApiQuery({ name: 'withTxsRelayedByAddress', description: 'Include transactions that were relayed by the address', required: false })
10211034
async getAccountTransfers(
10221035
@Param('address', ParseAddressPipe) address: string,
10231036
@Query('from', new DefaultValuePipe(0), ParseIntPipe) from: number,
@@ -1041,10 +1054,12 @@ export class AccountController {
10411054
@Query('withUsername', ParseBoolPipe) withUsername?: boolean,
10421055
@Query('withBlockInfo', ParseBoolPipe) withBlockInfo?: boolean,
10431056
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
1057+
@Query('isScCall', ParseBoolPipe) isScCall?: boolean,
10441058
@Query('withLogs', ParseBoolPipe) withLogs?: boolean,
10451059
@Query('withOperations', ParseBoolPipe) withOperations?: boolean,
10461060
@Query('withActionTransferValue', ParseBoolPipe) withActionTransferValue?: boolean,
10471061
@Query('withRefunds', ParseBoolPipe) withRefunds?: boolean,
1062+
@Query('withTxsRelayedByAddress', ParseBoolPipe) withTxsRelayedByAddress?: boolean,
10481063
): Promise<Transaction[]> {
10491064
const options = TransactionQueryOptions.applyDefaultOptions(
10501065
size, { withScamInfo, withUsername, withBlockInfo, withOperations, withLogs, withActionTransferValue });
@@ -1067,6 +1082,8 @@ export class AccountController {
10671082
relayer,
10681083
round,
10691084
withRefunds,
1085+
withTxsRelayedByAddress,
1086+
isScCall,
10701087
}),
10711088
new QueryPagination({ from, size }),
10721089
options,
@@ -1075,7 +1092,7 @@ export class AccountController {
10751092
}
10761093

10771094
@Get("/accounts/:address/transfers/count")
1078-
@ApiOperation({ summary: 'Account transfer count', description: 'Return total count of tranfers triggerred by a user account (type = Transaction), as well as transfers triggerred by smart contracts (type = SmartContractResult)' })
1095+
@ApiOperation({ summary: 'Account transfer count', description: 'Return total count of transfers triggerred by a user account (type = Transaction), as well as transfers triggerred by smart contracts (type = SmartContractResult)' })
10791096
@ApiOkResponse({ type: Number })
10801097
@ApiQuery({ name: 'sender', description: 'Address of the transfer sender', required: false })
10811098
@ApiQuery({ name: 'receiver', description: 'Search by multiple receiver addresses, comma-separated', required: false })
@@ -1089,6 +1106,7 @@ export class AccountController {
10891106
@ApiQuery({ name: 'before', description: 'Before timestamp', required: false })
10901107
@ApiQuery({ name: 'after', description: 'After timestamp', required: false })
10911108
@ApiQuery({ name: 'round', description: 'Round number', required: false })
1109+
@ApiQuery({ name: 'isScCall', description: 'Returns sc call transactions details', required: false, type: Boolean })
10921110
@ApiQuery({ name: 'senderOrReceiver', description: 'One address that current address interacted with', required: false })
10931111
@ApiQuery({ name: 'withRefunds', description: 'Include refund transactions', required: false })
10941112
async getAccountTransfersCount(
@@ -1106,6 +1124,7 @@ export class AccountController {
11061124
@Query('after', ParseIntPipe) after?: number,
11071125
@Query('round', ParseIntPipe) round?: number,
11081126
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
1127+
@Query('isScCall', ParseBoolPipe) isScCall?: boolean,
11091128
@Query('withRefunds', ParseBoolPipe) withRefunds?: boolean,
11101129
): Promise<number> {
11111130
return await this.transferService.getTransfersCount(new TransactionFilter({
@@ -1123,6 +1142,7 @@ export class AccountController {
11231142
after,
11241143
senderOrReceiver,
11251144
round,
1145+
isScCall,
11261146
withRefunds,
11271147
}));
11281148
}
@@ -1145,6 +1165,7 @@ export class AccountController {
11451165
@Query('round', ParseIntPipe) round?: number,
11461166
@Query('senderOrReceiver', ParseAddressPipe) senderOrReceiver?: string,
11471167
@Query('withRefunds', ParseBoolPipe) withRefunds?: boolean,
1168+
@Query('isScCall', ParseBoolPipe) isScCall?: boolean,
11481169
): Promise<number> {
11491170
return await this.transferService.getTransfersCount(new TransactionFilter({
11501171
address,
@@ -1162,6 +1183,7 @@ export class AccountController {
11621183
senderOrReceiver,
11631184
round,
11641185
withRefunds,
1186+
isScCall,
11651187
}));
11661188
}
11671189

0 commit comments

Comments
 (0)