Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Oct 8, 2024
1 parent 98324ea commit 4bf5c33
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pricing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"build": "tsc -p tsconfig.build.json",
"check-types": "tsc --noEmit -p ./tsconfig.json",
"clean": "rm -rf dist",
"clean": "rm -rf dist/",
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"",
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"",
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"",
Expand Down
4 changes: 4 additions & 0 deletions packages/pricing/src/providers/coingecko.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export class CoingeckoProvider implements IPricingProvider {
throw new UnsupportedChainException(chainId);
}

if (startTimestampMs > endTimestampMs) {
return undefined;
}

const startTimestampSecs = Math.floor(startTimestampMs / 1000);
const endTimestampSecs = Math.floor(endTimestampMs / 1000);

Expand Down
11 changes: 11 additions & 0 deletions packages/pricing/test/providers/coingecko.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ describe("CoingeckoProvider", () => {
expect(result).toBeUndefined();
});

it("return undefined when endTimestamp is greater than startTimestamp", async () => {
const result = await provider.getTokenPrice(
1,
"0x1234567890123456789012345678901234567890" as Address,
1609545600000, // startTimestamp
1609459200000, // endTimestamp
);

expect(result).toBeUndefined();
});

it("return undefined if 400 family error", async () => {
mock.onGet().replyOnce(400, "Bad Request");

Expand Down

0 comments on commit 4bf5c33

Please sign in to comment.