Skip to content

Commit

Permalink
fix(core-database): improve search by address (#4786)
Browse files Browse the repository at this point in the history
* Search only by payments

* Fix tests
  • Loading branch information
sebastijankuzner committed Jul 12, 2023
1 parent 161713c commit ccddcec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
27 changes: 3 additions & 24 deletions __tests__/unit/core-database/transaction-filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }] } },
],
});
});
Expand All @@ -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" }] } },
],
});
});
Expand Down Expand Up @@ -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" }] } },
],
});
});
Expand Down
11 changes: 4 additions & 7 deletions packages/core-database/src/transaction-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,10 @@ export class TransactionFilter implements Contracts.Database.TransactionFilter {
value: criteria,
};

const multipaymentRecipientIdExpression: Contracts.Search.AndExpression<Transaction> = {
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<Transaction> = {
op: "contains",
property: "asset",
value: { payments: [{ recipientId: criteria }] },
};

return {
Expand Down

0 comments on commit ccddcec

Please sign in to comment.