Skip to content

Commit

Permalink
refactor(core-api): fallback to core typegroup if querying by t… (#3147)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated authored and faustbrian committed Oct 28, 2019
1 parent 3e17881 commit 4787d44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ describe("Transactions Business Repository", () => {
operator: expect.anything(),
value: Enums.TransactionType.Transfer,
},
{
field: "typeGroup",
operator: expect.anything(),
value: Enums.TransactionTypeGroup.Core,
},
],
}),
);
Expand Down Expand Up @@ -505,6 +510,11 @@ describe("Transactions Business Repository", () => {
operator: expect.anything(),
value: "id",
},
{
field: "typeGroup",
operator: expect.anything(),
value: Enums.TransactionTypeGroup.Core,
},
],
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ export class TransactionsBusinessRepository implements Database.ITransactionsBus
}

public async findByHtlcLocks(lockIds: string[]): Promise<Interfaces.ITransactionData[]> {
return this.mapBlocksToTransactions(await this.databaseServiceProvider().connection.transactionsRepository.findByHtlcLocks(lockIds));
return this.mapBlocksToTransactions(
await this.databaseServiceProvider().connection.transactionsRepository.findByHtlcLocks(lockIds),
);
}

private getPublicKeyFromAddress(senderId: string): string {
Expand Down Expand Up @@ -184,6 +186,10 @@ export class TransactionsBusinessRepository implements Database.ITransactionsBus
private parseSearchParameters(params: any, sequenceOrder: "asc" | "desc" = "desc"): Database.ISearchParameters {
const databaseService: Database.IDatabaseService = this.databaseServiceProvider();

if (params.type !== undefined && params.typeGroup === undefined) {
params.typeGroup = Enums.TransactionTypeGroup.Core;
}

if (params.senderId) {
const senderPublicKey = this.getPublicKeyFromAddress(params.senderId);

Expand Down

0 comments on commit 4787d44

Please sign in to comment.