diff --git a/src/clients/coinmarketcap-client.model.ts b/src/clients/coinmarketcap-client.model.ts index 0b32d66..c003162 100644 --- a/src/clients/coinmarketcap-client.model.ts +++ b/src/clients/coinmarketcap-client.model.ts @@ -1,4 +1,4 @@ -export type aeUsdQuoteData = { +export type AeUsdQuoteData = { 1700: { id: number; name: string; @@ -27,12 +27,12 @@ export type aeUsdQuoteData = { }; }; -export type CoinMarketCapResponse = { - status: CoinMarketCapStatus; +export type CoinmarketcapResponse = { + status: CoinmarketcapStatus; data: T; }; -export type CoinMarketCapStatus = { +export type CoinmarketcapStatus = { timestamp: Date; error_code: number; error_message: string; diff --git a/src/clients/coinmarketcap-client.service.spec.ts b/src/clients/coinmarketcap-client.service.spec.ts index 5b35970..6713260 100644 --- a/src/clients/coinmarketcap-client.service.spec.ts +++ b/src/clients/coinmarketcap-client.service.spec.ts @@ -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(), @@ -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); diff --git a/src/clients/coinmarketcap-client.service.ts b/src/clients/coinmarketcap-client.service.ts index 6cb79d3..ff1ef0e 100644 --- a/src/clients/coinmarketcap-client.service.ts +++ b/src/clients/coinmarketcap-client.service.ts @@ -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'; @@ -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>(url); + return this.get>(url); } private async get(url: string): Promise { diff --git a/src/tasks/pair-liquidity-info-history-importer/pair-liquidity-info-history-importer-v2.service.spec.ts b/src/tasks/pair-liquidity-info-history-importer/pair-liquidity-info-history-importer-v2.service.spec.ts index d4db885..32dc5ce 100644 --- a/src/tasks/pair-liquidity-info-history-importer/pair-liquidity-info-history-importer-v2.service.spec.ts +++ b/src/tasks/pair-liquidity-info-history-importer/pair-liquidity-info-history-importer-v2.service.spec.ts @@ -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, @@ -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([ @@ -190,7 +190,7 @@ describe('PairLiquidityInfoHistoryImporterV2Service', () => { {}, ); mockCoinmarketcapClient.getHistoricalPriceDataThrottled.mockResolvedValue( - coinmarketCapResponseAeUsdQuoteData, + coinmarketcapResponseAeUsdQuoteData, ); mockPairLiquidityInfoHistoryV2Db.upsert.mockResolvedValue(null); mockMdwClient.getContractLogsUntilCondition.mockResolvedValue([ @@ -292,7 +292,7 @@ describe('PairLiquidityInfoHistoryImporterV2Service', () => { contractLog5, ]); mockCoinmarketcapClient.getHistoricalPriceDataThrottled.mockResolvedValue( - coinmarketCapResponseAeUsdQuoteData, + coinmarketcapResponseAeUsdQuoteData, ); mockPairLiquidityInfoHistoryV2Db.upsert.mockResolvedValue(null); mockPairLiquidityInfoHistoryV2ErrorDb.upsert.mockResolvedValue(null); diff --git a/test/mock-data/pair-liquidity-info-history-mock-data.ts b/test/mock-data/pair-liquidity-info-history-mock-data.ts index 5c2491f..5103469 100644 --- a/test/mock-data/pair-liquidity-info-history-mock-data.ts +++ b/test/mock-data/pair-liquidity-info-history-mock-data.ts @@ -256,7 +256,7 @@ export const contractLog8 = { log_idx: '3', }; -export const coinmarketCapResponseAeUsdQuoteData = { +export const coinmarketcapResponseAeUsdQuoteData = { data: { 1700: { quotes: [{ quote: { USD: { price: 0.050559 } } }],