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

Merge development feat cs e2e tests #1423

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
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
Loading