Skip to content

Commit

Permalink
Merge pull request #1423 from multiversx/merge-development-feat-cs-e2…
Browse files Browse the repository at this point in the history
…e-tests-dec12

Merge development feat cs e2e tests
  • Loading branch information
bogdan-rosianu authored Dec 12, 2024
2 parents 3edb5bb + adeeb5a commit 642aa7f
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 230 deletions.
1 change: 1 addition & 0 deletions src/common/gateway/entities/gateway.component.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum GatewayComponentRequest {
networkEconomics = 'networkEconomics',
networkTotalStaked = 'networkTotalStaked',
addressDetails = 'addressDetails',
addressesBulk = 'addressesBulk',
addressEsdt = 'addressEsdt',
addressEsdtHistorical = 'addressEsdtHistorical',
addressEsdtBalance = 'addressEsdtBalance',
Expand Down
5 changes: 5 additions & 0 deletions src/common/gateway/gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export class GatewayService {
return result;
}

async getAccountsBulk(addresses: string[]): Promise<Account[]> {
const result = await this.create('address/bulk', GatewayComponentRequest.addressesBulk, addresses);
return result.accounts;
}

async getEsdtSupply(identifier: string): Promise<EsdtSupply> {
const result = await this.get(`network/esdt/supply/${identifier}`, GatewayComponentRequest.esdtSupply);
return result;
Expand Down
36 changes: 27 additions & 9 deletions src/common/indexer/elastic/elastic.indexer.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SmartContractResultFilter } from "src/endpoints/sc-results/entities/sma
import { ApplicationFilter } from "src/endpoints/applications/entities/application.filter";
import { NftType } from "../entities/nft.type";
import { EventsFilter } from "src/endpoints/events/entities/events.filter";
import { ScriptQuery } from "./script.query";

@Injectable()
export class ElasticIndexerHelper {
Expand Down Expand Up @@ -93,7 +94,7 @@ export class ElasticIndexerHelper {
QueryType.Nested('roles', [new MatchQuery('roles.ESDTRoleNFTUpdateAttributes', address)]),
QueryType.Nested('roles', [new MatchQuery('roles.ESDTRoleNFTAddURI', address)]),
QueryType.Nested('roles', [new MatchQuery('roles.ESDTTransferRole', address)]),
]
],
));
}

Expand Down Expand Up @@ -253,7 +254,7 @@ export class ElasticIndexerHelper {
QueryType.Should([
QueryType.Match('nft_scamInfoType', 'scam'),
QueryType.Match('nft_scamInfoType', 'potentialScam'),
])
]),
);
}

Expand Down Expand Up @@ -309,12 +310,16 @@ export class ElasticIndexerHelper {
smartContractResultConditions.push(QueryType.Match('sender', filter.address));
}

let mustNotQueries: AbstractQuery[] = [
QueryType.Exists('canBeIgnored'),
];
if (filter.withRefunds) {
mustNotQueries = [];
}
elasticQuery = elasticQuery.withCondition(QueryConditionOptions.should, QueryType.Must([
QueryType.Match('type', 'unsigned'),
QueryType.Should(smartContractResultConditions),
], [
QueryType.Exists('canBeIgnored'),
]))
], mustNotQueries))
.withCondition(QueryConditionOptions.should, QueryType.Must([
QueryType.Should([QueryType.Match('type', 'normal')]),
QueryType.Should([
Expand Down Expand Up @@ -429,7 +434,7 @@ export class ElasticIndexerHelper {
[
QueryType.Match('currentOwner', address),
...rolesConditions,
]
],
))
.withMustMatchCondition('token', filter.identifier)
.withMustMatchCondition('currentOwner', filter.owner);
Expand Down Expand Up @@ -507,9 +512,22 @@ export class ElasticIndexerHelper {
}

public buildTransactionFilterQuery(filter: TransactionFilter, address?: string): ElasticQuery {
let elasticQuery = ElasticQuery.create()
.withMustMatchCondition('type', 'normal')
.withMustMatchCondition('senderShard', filter.senderShard)
let elasticQuery = ElasticQuery.create();

if (!filter.withRelayedScresults) {
elasticQuery = elasticQuery.withMustMatchCondition('type', 'normal');
} else {
elasticQuery = elasticQuery.withShouldCondition([
QueryType.Match('type', 'normal'),
QueryType.Must([
QueryType.Exists('relayerAddr'),
QueryType.Match('type', 'unsigned'),
new ScriptQuery(`doc['originalTxHash'].size() > 0 && doc['prevTxHash'].size() > 0 && doc['originalTxHash'].value == doc['prevTxHash'].value`),
]),
]);
}

elasticQuery = elasticQuery.withMustMatchCondition('senderShard', filter.senderShard)
.withMustMatchCondition('receiverShard', filter.receiverShard)
.withMustMatchCondition('miniBlockHash', filter.miniBlockHash)
.withMustMultiShouldCondition(filter.hashes, hash => QueryType.Match('_id', hash))
Expand Down
14 changes: 14 additions & 0 deletions src/common/indexer/elastic/script.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { AbstractQuery } from "@multiversx/sdk-nestjs-elastic";

// TODO: remove this and use ScriptQuery from sdk-nestjs when PR #247 is merged
export class ScriptQuery extends AbstractQuery {
constructor(
private readonly source: string | undefined,
) {
super();
}

getQuery(): any {
return { script: { script: { source: this.source, lang: 'painless' } } };
}
}
Loading

0 comments on commit 642aa7f

Please sign in to comment.