Skip to content

Commit

Permalink
update price history endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bakoushin committed Dec 16, 2024
1 parent bef3560 commit cfe2bfc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/priceHistory/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('watchFetchTokenPriceHistory', () => {

expect(mockFetch).toHaveBeenCalledTimes(1)
expect(mockFetch).toHaveBeenCalledWith(
`${networkConfig.blockchainApiUrl}/tokensInfo/${mockCusdTokenId}/priceHistory?startTimestamp=1700378258000&endTimestamp=1702941458000`,
`${networkConfig.getTokenPriceHistoryUrl}?tokenId=${encodeURIComponent(mockCusdTokenId)}&startTimestamp=1700378258000&endTimestamp=1702941458000`,
expect.any(Object)
)
})
Expand Down
3 changes: 2 additions & 1 deletion src/priceHistory/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ export async function fetchTokenPriceHistory(
endTimestamp: number
): Promise<Price[]> {
const queryParams = new URLSearchParams({
tokenId,
startTimestamp: `${startTimestamp}`,
endTimestamp: `${endTimestamp}`,
}).toString()

const url = `${networkConfig.blockchainApiUrl}/tokensInfo/${tokenId}/priceHistory?${queryParams}`
const url = `${networkConfig.getTokenPriceHistoryUrl}?${queryParams}`
const response = await fetchWithTimeout(url)
if (!response.ok) {
throw new Error(
Expand Down
6 changes: 6 additions & 0 deletions src/web3/networkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface NetworkConfig {
getWalletTransactionsUrl: string
getWalletBalancesUrl: string
getExchangeRateUrl: string
getTokenPriceHistoryUrl: string
getCicoQuotesUrl: string
getCeloNewsFeedUrl: string
}
Expand Down Expand Up @@ -244,6 +245,9 @@ const GET_WALLET_BALANCES_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/getWalletBalance
const GET_EXCHANGE_RATE_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/getExchangeRate`
const GET_EXCHANGE_RATE_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/getExchangeRate`

const GET_TOKEN_PRICE_HISTORY_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/getTokenPriceHistory`
const GET_TOKEN_PRICE_HISTORY_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/getTokenPriceHistory`

const GET_CICO_QUOTES_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/getCicoQuotes`
const GET_CICO_QUOTES_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/getCicoQuotes`

Expand Down Expand Up @@ -372,6 +376,7 @@ const networkConfigs: { [testnet: string]: NetworkConfig } = {
getWalletTransactionsUrl: GET_WALLET_TRANSACTIONS_ALFAJORES,
getWalletBalancesUrl: GET_WALLET_BALANCES_ALFAJORES,
getExchangeRateUrl: GET_EXCHANGE_RATE_ALFAJORES,
getTokenPriceHistoryUrl: GET_TOKEN_PRICE_HISTORY_ALFAJORES,
getCicoQuotesUrl: GET_CICO_QUOTES_ALFAJORES,
getCeloNewsFeedUrl: GET_CELO_NEWS_FEED_ALFAJORES,
},
Expand Down Expand Up @@ -459,6 +464,7 @@ const networkConfigs: { [testnet: string]: NetworkConfig } = {
getWalletTransactionsUrl: GET_WALLET_TRANSACTIONS_MAINNET,
getWalletBalancesUrl: GET_WALLET_BALANCES_MAINNET,
getExchangeRateUrl: GET_EXCHANGE_RATE_MAINNET,
getTokenPriceHistoryUrl: GET_TOKEN_PRICE_HISTORY_MAINNET,
getCicoQuotesUrl: GET_CICO_QUOTES_MAINNET,
getCeloNewsFeedUrl: GET_CELO_NEWS_FEED_MAINNET,
},
Expand Down

0 comments on commit cfe2bfc

Please sign in to comment.