Skip to content

Commit

Permalink
feat: PR comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Panteleymonchuk <[email protected]>
  • Loading branch information
panteleymonchuk committed Apr 26, 2024
1 parent b73d6f0 commit 1207d24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/src/utils/nova/searchExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ServiceFactory } from "../../factories/serviceFactory";
import { ISearchResponse } from "../../models/api/nova/ISearchResponse";
import { INetwork } from "../../models/db/INetwork";
import { NovaApiService } from "../../services/nova/novaApiService";
import { ValidationHelper } from "../validationHelper";

export class SearchExecutor {
/**
Expand Down Expand Up @@ -120,6 +121,7 @@ export class SearchExecutor {
promisesResult = {
anchorId: searchQuery.anchorId,
};
resolve();
} else {
reject(new Error("Anchor id fetch failed"));
}
Expand All @@ -143,11 +145,11 @@ export class SearchExecutor {
};
resolve();
} else {
reject(new Error("Anchor id fetch failed"));
reject(new Error("Delegation id fetch failed"));
}
})
.catch((_) => {
reject(new Error("Anchor id fetch failed"));
reject(new Error("Delegation id fetch failed"));
});
}),
);
Expand Down Expand Up @@ -203,9 +205,9 @@ export class SearchExecutor {
this.apiService
.getSlotCommitment(searchQuery.slotIndex)
.then((response) => {
if (searchQuery.slotIndex) {
if (ValidationHelper.isNumber(response?.slot?.slot)) {
promisesResult = {
slotIndex: String(searchQuery.slotIndex),
slotIndex: String(response.slot?.slot),
};
resolve();
} else {
Expand All @@ -225,7 +227,7 @@ export class SearchExecutor {
this.apiService
.getCommitment(searchQuery.slotCommitmentId)
.then((response) => {
if (response?.slot?.slot) {
if (ValidationHelper.isNumber(response?.slot?.slot)) {
promisesResult = {
slotIndex: String(response.slot.slot),
};
Expand Down
4 changes: 4 additions & 0 deletions api/src/utils/validationHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class ValidationHelper {
}
}

public static isNumber(value?: number | null): boolean {
return typeof value === "number" && !Number.isNaN(value);
}

/**
* Does the string have some content and is a decimal number.
* @param str The string to validate.
Expand Down

0 comments on commit 1207d24

Please sign in to comment.