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: Remove old CeloGoldHistoryChart #5307

Merged
merged 20 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/account/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parsePhoneNumber } from '@celo/phone-utils'
import { ADDRESS_LENGTH } from 'src/exchange/reducer'

const ADDRESS_LENGTH = 42

export const isAddressFormat = (content: string): boolean => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to your PR, but guess this is something we could replace with a viem helper, which I believe we use in the qr scanner. Maybe leave a note / make a tech debt issue?

return content.startsWith('0x') && content.length === ADDRESS_LENGTH
Expand Down
6 changes: 1 addition & 5 deletions src/alert/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Action } from '@reduxjs/toolkit'
import { Actions, ActionTypes, AlertTypes } from 'src/alert/actions'
import { ErrorMessages } from 'src/app/ErrorMessages'
import { ActionTypes as ExchangeActionTypes } from 'src/exchange/actions'
import { RootState } from 'src/redux/reducers'

export enum ErrorDisplayType {
Expand All @@ -24,10 +23,7 @@ type State = Alert | null

const initialState = null

export const reducer = (
state: State = initialState,
action: ActionTypes | ExchangeActionTypes
): State => {
export const reducer = (state: State = initialState, action: ActionTypes): State => {
switch (action.type) {
case Actions.SHOW:
return {
Expand Down
2 changes: 1 addition & 1 deletion src/app/reducers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Platform } from 'react-native'
import { BIOMETRY_TYPE } from 'react-native-keychain'
import { Actions, ActionTypes, AppState, MultichainBetaStatus } from 'src/app/actions'
import { CeloNewsConfig } from 'src/celoNews/types'
import { SuperchargeTokenConfigByToken } from 'src/consumerIncentives/types'
import { CeloNewsConfig } from 'src/exchange/types'
import { REMOTE_CONFIG_VALUES_DEFAULTS } from 'src/firebase/remoteConfigValuesDefaults'
import { Screens } from 'src/navigator/Screens'
import { getRehydratePayload, REHYDRATE, RehydrateAction } from 'src/redux/persist-helper'
Expand Down
14 changes: 7 additions & 7 deletions src/app/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import { findBestAvailableLanguage } from 'react-native-localize'
import { eventChannel } from 'redux-saga'
import { e164NumberSelector } from 'src/account/selectors'
import { AppEvents, InviteEvents } from 'src/analytics/Events'
import { HooksEnablePreviewOrigin } from 'src/analytics/types'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import { HooksEnablePreviewOrigin } from 'src/analytics/types'
import {
Actions,
OpenDeepLink,
OpenUrlAction,
SetAppState,
androidMobileServicesAvailabilityChecked,
appLock,
inAppReviewRequested,
inviteLinkConsumed,
minAppVersionDetermined,
OpenDeepLink,
openDeepLink,
OpenUrlAction,
phoneNumberVerificationMigrated,
SetAppState,
setAppState,
setSupportedBiometryType,
updateRemoteConfigValues,
Expand All @@ -38,13 +38,13 @@ import {
sentryNetworkErrorsSelector,
shouldRunVerificationMigrationSelector,
} from 'src/app/selectors'
import { CeloNewsConfig } from 'src/celoNews/types'
import { DEFAULT_APP_LANGUAGE, FETCH_TIMEOUT_DURATION, isE2EEnv } from 'src/config'
import { claimRewardsSuccess } from 'src/consumerIncentives/slice'
import { SuperchargeTokenConfigByToken } from 'src/consumerIncentives/types'
import { handleDappkitDeepLink } from 'src/dappkit/dappkit'
import { CeloNewsConfig } from 'src/exchange/types'
import { FiatAccountSchemaCountryOverrides } from 'src/fiatconnect/types'
import { FiatExchangeFlow } from 'src/fiatExchanges/utils'
import { FiatAccountSchemaCountryOverrides } from 'src/fiatconnect/types'
import { appVersionDeprecationChannel, fetchRemoteConfigValues } from 'src/firebase/firebase'
import { initI18n } from 'src/i18n'
import {
Expand All @@ -70,9 +70,9 @@ import { getFeatureGate, patchUpdateStatsigUser, setupOverridesFromLaunchArgs }
import { StatsigFeatureGates } from 'src/statsig/types'
import { swapSuccess } from 'src/swap/slice'
import { NetworkId } from 'src/transactions/types'
import Logger from 'src/utils/Logger'
import { ensureError } from 'src/utils/ensureError'
import { isDeepLink, navigateToURI } from 'src/utils/linking'
import Logger from 'src/utils/Logger'
import { safely } from 'src/utils/safely'
import { ONE_DAY_IN_MILLIS } from 'src/utils/time'
import { isWalletConnectEnabled } from 'src/walletConnect/saga'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from 'react'
import { Provider } from 'react-redux'
import { CeloNewsEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import CeloNewsFeed from 'src/exchange/CeloNewsFeed'
import { CeloNewsArticles } from 'src/exchange/types'
import CeloNewsFeed from 'src/celoNews/CeloNewsFeed'
import { CeloNewsArticles } from 'src/celoNews/types'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import networkConfig from 'src/web3/networkConfig'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { FlatList, ListRenderItemInfo, StyleSheet, Text, View } from 'react-nati
import { CeloNewsEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import { celoNewsConfigSelector } from 'src/app/selectors'
import CeloNewsFeedItem from 'src/celoNews/CeloNewsFeedItem'
import { CeloNewsArticle, CeloNewsArticles } from 'src/celoNews/types'
import Button, { BtnSizes, BtnTypes } from 'src/components/Button'
import EmptyView from 'src/components/EmptyView'
import CeloNewsFeedItem from 'src/exchange/CeloNewsFeedItem'
import { CeloNewsArticle, CeloNewsArticles } from 'src/exchange/types'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { useSelector } from 'src/redux/hooks'
import colors from 'src/styles/colors'
import { typeScale } from 'src/styles/fonts'
import { Spacing } from 'src/styles/styles'
import { fetchWithTimeout } from 'src/utils/fetchWithTimeout'
import Logger from 'src/utils/Logger'
import { fetchWithTimeout } from 'src/utils/fetchWithTimeout'
import networkConfig from 'src/web3/networkConfig'

const TAG = 'exchange/CeloNewsFeed'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fireEvent, render } from '@testing-library/react-native'
import React from 'react'
import { CeloNewsEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import CeloNewsFeedItem from 'src/exchange/CeloNewsFeedItem'
import CeloNewsFeedItem from 'src/celoNews/CeloNewsFeedItem'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as React from 'react'
import { Image, StyleSheet, Text, View } from 'react-native'
import { CeloNewsEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import { CeloNewsArticle } from 'src/celoNews/types'
import SkeletonPlaceholder from 'src/components/SkeletonPlaceholder'
import Touchable from 'src/components/Touchable'
import { CeloNewsArticle } from 'src/exchange/types'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import colors from 'src/styles/colors'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { render, within } from '@testing-library/react-native'
import React from 'react'
import { Provider } from 'react-redux'
import ExchangeHomeScreen from 'src/exchange/ExchangeHomeScreen'
import { getFeatureGate } from 'src/statsig'
import ExchangeHomeScreen from 'src/celoNews/ExchangeHomeScreen'
import { createMockStore } from 'test/utils'
import {
exchangePriceHistory,
mockCeloTokenId,
mockCusdTokenId,
mockTokenBalances,
priceHistory,
} from 'test/values'
import { mockCeloTokenId, mockCusdTokenId, mockTokenBalances, priceHistory } from 'test/values'

jest.mock('src/statsig')

Expand All @@ -21,9 +14,6 @@ const store = createMockStore({
[mockCeloTokenId]: mockTokenBalances[mockCeloTokenId],
},
},
exchange: {
history: exchangePriceHistory,
},
priceHistory: {
[mockCeloTokenId]: priceHistory,
},
Expand All @@ -34,19 +24,7 @@ describe('ExchangeHomeScreen', () => {
jest.resetAllMocks()
})

it('renders the price chart using firebase by default', async () => {
const { getByTestId } = render(
<Provider store={store}>
<ExchangeHomeScreen />
</Provider>
)

// Check we can see the price chart
expect(getByTestId('PriceChart')).toBeTruthy()
})

it('renders the price chart using PriceHistoryChart and blockchain api when enabled', async () => {
jest.mocked(getFeatureGate).mockReturnValue(true)
it('renders the price chart using PriceHistoryChart and blockchain api', async () => {
const { getByTestId } = render(
<Provider store={store}>
<ExchangeHomeScreen />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import Animated from 'react-native-reanimated'
import { SafeAreaView } from 'react-native-safe-area-context'
import { CeloExchangeEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import CeloNewsFeed from 'src/celoNews/CeloNewsFeed'
import Touchable from 'src/components/Touchable'
import CeloGoldHistoryChart from 'src/exchange/CeloGoldHistoryChart'
import CeloNewsFeed from 'src/exchange/CeloNewsFeed'
import { exchangeHistorySelector } from 'src/exchange/reducer'
import InfoIcon from 'src/icons/InfoIcon'
import { LocalCurrencyCode } from 'src/localCurrency/consts'
import { convertDollarsToLocalAmount } from 'src/localCurrency/convert'
Expand All @@ -20,8 +18,6 @@ import { Screens } from 'src/navigator/Screens'
import PriceHistoryChart from 'src/priceHistory/PriceHistoryChart'
import { useSelector } from 'src/redux/hooks'
import DisconnectBanner from 'src/shared/DisconnectBanner'
import { getFeatureGate } from 'src/statsig'
import { StatsigFeatureGates } from 'src/statsig/types'
import colors from 'src/styles/colors'
import fontStyles from 'src/styles/fonts'
import { Spacing } from 'src/styles/styles'
Expand Down Expand Up @@ -70,25 +66,16 @@ function ExchangeHomeScreen() {
const tokensBySymbol = useSelector(tokensBySymbolSelector)
const localCurrencyCode = useSelector(getLocalCurrencyCode)
const localExchangeRate = useSelector(usdToLocalCurrencyRateSelector)
const exchangeHistory = useSelector(exchangeHistorySelector)
const usePriceHistoryFromBlockchainApi = getFeatureGate(
StatsigFeatureGates.USE_PRICE_HISTORY_FROM_BLOCKCHAIN_API
)
const historicalPriceUsd = tokensBySymbol.CGLD?.historicalPricesUsd?.lastDay.price

const exchangeHistoryLength = exchangeHistory.aggregatedExchangeRates.length
const lastKnownPriceUsd =
tokensBySymbol.CGLD?.lastKnownPriceUsd ||
(exchangeHistoryLength &&
exchangeHistory.aggregatedExchangeRates[exchangeHistoryLength - 1].exchangeRate) ||
new BigNumber(0)
tokensBySymbol.CGLD?.lastKnownPriceUsd || historicalPriceUsd || new BigNumber(0)

const currentGoldRateInLocalCurrency = dollarsToLocal(lastKnownPriceUsd)
let rateChangeInPercentage, rateWentUp

if (exchangeHistoryLength) {
const oldestGoldRateInLocalCurrency = dollarsToLocal(
exchangeHistory.aggregatedExchangeRates[0].exchangeRate
)
if (historicalPriceUsd) {
const oldestGoldRateInLocalCurrency = dollarsToLocal(historicalPriceUsd)
if (oldestGoldRateInLocalCurrency) {
const rateChange = currentGoldRateInLocalCurrency?.minus(oldestGoldRateInLocalCurrency)
rateChangeInPercentage = currentGoldRateInLocalCurrency
Expand Down Expand Up @@ -158,16 +145,14 @@ function ExchangeHomeScreen() {
</View>
</View>

{usePriceHistoryFromBlockchainApi && networkConfig.celoTokenId ? (
{networkConfig.celoTokenId && (
<PriceHistoryChart
tokenId={networkConfig.celoTokenId}
testID={`CeloNews/Chart/${networkConfig.celoTokenId}`}
chartPadding={Spacing.Thick24}
color={colors.goldBrand}
containerStyle={styles.chartContainer}
/>
) : (
<CeloGoldHistoryChart testID="PriceChart" />
)}
<CeloNewsFeed />
</SafeAreaView>
Expand Down
File renamed without changes.
91 changes: 0 additions & 91 deletions src/exchange/CeloGoldHistoryChart.test.tsx

This file was deleted.