From f8df985a039c4cfc6475cf0f16d717f2990a6a8f Mon Sep 17 00:00:00 2001 From: Sebastijan K <58827427+sebastijankuzner@users.noreply.github.com> Date: Wed, 12 Jul 2023 13:05:57 +0200 Subject: [PATCH] merge: cherry pick from develop (#4788) fix(core-database): improve search by address (#4786) * Search only by payments * Fix tests --- .../core-database/transaction-filter.test.ts | 27 +++---------------- .../core-database/src/transaction-filter.ts | 11 +++----- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/__tests__/unit/core-database/transaction-filter.test.ts b/__tests__/unit/core-database/transaction-filter.test.ts index 55be3523f3..5b766fa8ec 100644 --- a/__tests__/unit/core-database/transaction-filter.test.ts +++ b/__tests__/unit/core-database/transaction-filter.test.ts @@ -50,14 +50,7 @@ describe("TransactionFilter.getExpression", () => { expressions: [ { property: "senderPublicKey", op: "equal", value: "456" }, { property: "recipientId", op: "equal", value: "123" }, - { - op: "and", - expressions: [ - { property: "typeGroup", op: "equal", value: Enums.TransactionTypeGroup.Core }, - { property: "type", op: "equal", value: Enums.TransactionType.MultiPayment }, - { property: "asset", op: "contains", value: { payments: [{ recipientId: "123" }] } }, - ], - }, + { property: "asset", op: "contains", value: { payments: [{ recipientId: "123" }] } }, ], }); }); @@ -74,14 +67,7 @@ describe("TransactionFilter.getExpression", () => { op: "or", expressions: [ { property: "recipientId", op: "equal", value: "123" }, - { - op: "and", - expressions: [ - { property: "typeGroup", op: "equal", value: Enums.TransactionTypeGroup.Core }, - { property: "type", op: "equal", value: Enums.TransactionType.MultiPayment }, - { property: "asset", op: "contains", value: { payments: [{ recipientId: "123" }] } }, - ], - }, + { property: "asset", op: "contains", value: { payments: [{ recipientId: "123" }] } }, ], }); }); @@ -132,14 +118,7 @@ describe("TransactionFilter.getExpression", () => { op: "or", expressions: [ { property: "recipientId", op: "equal", value: "123" }, - { - op: "and", - expressions: [ - { property: "typeGroup", op: "equal", value: Enums.TransactionTypeGroup.Core }, - { property: "type", op: "equal", value: Enums.TransactionType.MultiPayment }, - { property: "asset", op: "contains", value: { payments: [{ recipientId: "123" }] } }, - ], - }, + { property: "asset", op: "contains", value: { payments: [{ recipientId: "123" }] } }, ], }); }); diff --git a/packages/core-database/src/transaction-filter.ts b/packages/core-database/src/transaction-filter.ts index d17ce01044..19d90adc9e 100644 --- a/packages/core-database/src/transaction-filter.ts +++ b/packages/core-database/src/transaction-filter.ts @@ -133,13 +133,10 @@ export class TransactionFilter implements Contracts.Database.TransactionFilter { value: criteria, }; - const multipaymentRecipientIdExpression: Contracts.Search.AndExpression = { - op: "and", - expressions: [ - { op: "equal", property: "typeGroup", value: Enums.TransactionTypeGroup.Core }, - { op: "equal", property: "type", value: Enums.TransactionType.MultiPayment }, - { op: "contains", property: "asset", value: { payments: [{ recipientId: criteria }] } }, - ], + const multipaymentRecipientIdExpression: Contracts.Search.ContainsExpression = { + op: "contains", + property: "asset", + value: { payments: [{ recipientId: criteria }] }, }; return {