Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tokens): update price history endpoint #6367

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading