Skip to content

Commit

Permalink
refactor: improved type and variable naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrdlt committed Apr 25, 2024
1 parent 4bdac9f commit 72605bb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/clients/coinmarketcap-client.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type aeUsdQuoteData = {
export type AeUsdQuoteData = {
1700: {
id: number;
name: string;
Expand Down Expand Up @@ -27,12 +27,12 @@ export type aeUsdQuoteData = {
};
};

export type CoinMarketCapResponse<T> = {
status: CoinMarketCapStatus;
export type CoinmarketcapResponse<T> = {
status: CoinmarketcapStatus;
data: T;
};

export type CoinMarketCapStatus = {
export type CoinmarketcapStatus = {
timestamp: Date;
error_code: number;
error_message: string;
Expand Down
4 changes: 2 additions & 2 deletions src/clients/coinmarketcap-client.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpService } from '@/clients/http.service';
import resetAllMocks = jest.resetAllMocks;
import { RateLimiter } from 'limiter';

import { coinmarketCapResponseAeUsdQuoteData } from '@/test/mock-data/pair-liquidity-info-history-mock-data';
import { coinmarketcapResponseAeUsdQuoteData } from '@/test/mock-data/pair-liquidity-info-history-mock-data';

const mockHttpService = {
get: jest.fn(),
Expand All @@ -31,7 +31,7 @@ describe('CoinmarketcapClientService', () => {
it('should correctly calculate and fetch the latest 5 min interval for a given timestamp', async () => {
// Mock functions
mockHttpService.get.mockResolvedValue(
coinmarketCapResponseAeUsdQuoteData,
coinmarketcapResponseAeUsdQuoteData,
);
// Call function
await service.getHistoricalPriceDataThrottled(1704203935123);
Expand Down
6 changes: 3 additions & 3 deletions src/clients/coinmarketcap-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { RateLimiter } from 'limiter';

import {
aeUsdQuoteData,
CoinMarketCapResponse,
AeUsdQuoteData,
CoinmarketcapResponse,
} from '@/clients/coinmarketcap-client.model';
import { HttpService } from '@/clients/http.service';

Expand All @@ -28,7 +28,7 @@ export class CoinmarketcapClientService {
await this.rateLimiter.removeTokens(1);
const timeEnd = this.roundMicroBlockTimeDownTo5MinInterval(microBlockTime);
const url = `https://pro-api.coinmarketcap.com/v3/cryptocurrency/quotes/historical?id=${this.AE_CURRENCY_ID}&interval=${this.INTERVAL}&count=${this.COUNT}&time_end=${timeEnd}`;
return this.get<CoinMarketCapResponse<aeUsdQuoteData>>(url);
return this.get<CoinmarketcapResponse<AeUsdQuoteData>>(url);
}

private async get<T>(url: string): Promise<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PairLiquidityInfoHistoryImporterV2Service } from '@/tasks/pair-liquidit
import resetAllMocks = jest.resetAllMocks;
import { CoinmarketcapClientService } from '@/clients/coinmarketcap-client.service';
import {
coinmarketCapResponseAeUsdQuoteData,
coinmarketcapResponseAeUsdQuoteData,
contractLog1,
contractLog2,
contractLog3,
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('PairLiquidityInfoHistoryImporterV2Service', () => {
mockMdwClient.getContract.mockResolvedValue(pairContract);
mockMdwClient.getMicroBlock.mockResolvedValue(initialMicroBlock);
mockCoinmarketcapClient.getHistoricalPriceDataThrottled.mockResolvedValue(
coinmarketCapResponseAeUsdQuoteData,
coinmarketcapResponseAeUsdQuoteData,
);
mockPairLiquidityInfoHistoryV2Db.upsert.mockResolvedValue(null);
mockMdwClient.getContractLogsUntilCondition.mockResolvedValue([
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('PairLiquidityInfoHistoryImporterV2Service', () => {
{},
);
mockCoinmarketcapClient.getHistoricalPriceDataThrottled.mockResolvedValue(
coinmarketCapResponseAeUsdQuoteData,
coinmarketcapResponseAeUsdQuoteData,
);
mockPairLiquidityInfoHistoryV2Db.upsert.mockResolvedValue(null);
mockMdwClient.getContractLogsUntilCondition.mockResolvedValue([
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('PairLiquidityInfoHistoryImporterV2Service', () => {
contractLog5,
]);
mockCoinmarketcapClient.getHistoricalPriceDataThrottled.mockResolvedValue(
coinmarketCapResponseAeUsdQuoteData,
coinmarketcapResponseAeUsdQuoteData,
);
mockPairLiquidityInfoHistoryV2Db.upsert.mockResolvedValue(null);
mockPairLiquidityInfoHistoryV2ErrorDb.upsert.mockResolvedValue(null);
Expand Down
2 changes: 1 addition & 1 deletion test/mock-data/pair-liquidity-info-history-mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const contractLog8 = {
log_idx: '3',
};

export const coinmarketCapResponseAeUsdQuoteData = {
export const coinmarketcapResponseAeUsdQuoteData = {
data: {
1700: {
quotes: [{ quote: { USD: { price: 0.050559 } } }],
Expand Down

0 comments on commit 72605bb

Please sign in to comment.