From 90233b96c34a46b3780bd3414c9ff52158239d9f Mon Sep 17 00:00:00 2001 From: Finnian Jacobson-Schulte <140328381+finnian0826@users.noreply.github.com> Date: Tue, 30 Apr 2024 06:46:05 +1200 Subject: [PATCH] chore: Remove old CeloGoldHistoryChart (#5307) ### Description - Usage of CeloGoldHistoryChart removed - exchangeHistorySelector usage replaced with token.historicalPricesUsd.lastDay - sage/reducer/action cleaned up - exchange folder remaned to celoNews ### Test plan builds, root state schema updated ### Related issues - Fixes #ACT-1039 ### Backwards compatibility Yes ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - N/A --- e2e/src/usecases/Assets.js | 10 +- e2e/src/utils/utils.js | 16 + src/account/utils.ts | 3 +- src/alert/reducer.ts | 6 +- src/analytics/Events.tsx | 4 - src/analytics/Properties.tsx | 2 - src/analytics/docs.ts | 4 +- src/app/reducers.ts | 2 +- src/app/saga.ts | 14 +- .../CeloNewsFeed.test.tsx | 4 +- src/{exchange => celoNews}/CeloNewsFeed.tsx | 6 +- .../CeloNewsFeedItem.test.tsx | 2 +- .../CeloNewsFeedItem.tsx | 2 +- src/{exchange => celoNews}/types.ts | 0 src/exchange/CeloGoldHistoryChart.test.tsx | 91 ---- src/exchange/CeloGoldHistoryChart.tsx | 308 ------------- .../CeloGoldHistoryChart.test.tsx.snap | 406 ----------------- src/exchange/actions.ts | 22 - src/exchange/reducer.ts | 117 ----- src/firebase/saga.ts | 83 +--- src/redux/migrations.test.ts | 7 +- src/redux/migrations.ts | 14 +- src/redux/reducers.ts | 4 +- src/redux/sagas.ts | 8 +- src/redux/store.test.ts | 11 +- src/redux/store.ts | 2 +- src/statsig/constants.ts | 1 - src/statsig/types.ts | 1 - src/tokens/TokenDetails.test.tsx | 20 - src/tokens/TokenDetails.tsx | 21 +- src/transactions/reducer.ts | 3 +- test/RootStateSchema.json | 411 ++++++++---------- test/schemas.ts | 10 +- 33 files changed, 254 insertions(+), 1361 deletions(-) rename src/{exchange => celoNews}/CeloNewsFeed.test.tsx (98%) rename src/{exchange => celoNews}/CeloNewsFeed.tsx (97%) rename src/{exchange => celoNews}/CeloNewsFeedItem.test.tsx (96%) rename src/{exchange => celoNews}/CeloNewsFeedItem.tsx (98%) rename src/{exchange => celoNews}/types.ts (100%) delete mode 100644 src/exchange/CeloGoldHistoryChart.test.tsx delete mode 100644 src/exchange/CeloGoldHistoryChart.tsx delete mode 100644 src/exchange/__snapshots__/CeloGoldHistoryChart.test.tsx.snap delete mode 100644 src/exchange/actions.ts delete mode 100644 src/exchange/reducer.ts diff --git a/e2e/src/usecases/Assets.js b/e2e/src/usecases/Assets.js index 872d9bc9737..02b3d2dba9e 100644 --- a/e2e/src/usecases/Assets.js +++ b/e2e/src/usecases/Assets.js @@ -1,7 +1,12 @@ import { generateMnemonic } from '@celo/cryptographic-utils' import { DEFAULT_RECIPIENT_ADDRESS, SAMPLE_BACKUP_KEY } from '../utils/consts' import { launchApp } from '../utils/retries' -import { quickOnboarding, waitForElementByIdAndTap, waitForElementId } from '../utils/utils' +import { + quickOnboarding, + waitForElementByIdAndTap, + waitForElementId, + scrollIntoViewByTestId, +} from '../utils/utils' async function validateSendFlow(tokenSymbol) { // navigate to send amount screen to ensure the expected token symbol is pre-selected @@ -151,13 +156,14 @@ export default Assets = () => { if (learnMore) { it('learn more navigates to coingecko page', async () => { + await scrollIntoViewByTestId('TokenDetails/LearnMore', 'TokenDetailsScrollView') await waitForElementByIdAndTap('TokenDetails/LearnMore') await waitForElementId('RNWebView') await waitFor(element(by.text('www.coingecko.com'))) .toBeVisible() .withTimeout(10 * 1000) await element(by.id('WebViewScreen/CloseButton')).tap() - await waitForElementId('TokenDetails/AssetValue') + await waitForElementId('TokenBalanceItem') }) } diff --git a/e2e/src/utils/utils.js b/e2e/src/utils/utils.js index 166848bf0aa..cd52464265c 100644 --- a/e2e/src/utils/utils.js +++ b/e2e/src/utils/utils.js @@ -285,6 +285,22 @@ export async function scrollIntoView(scrollTo, scrollIn, speed = 350, direction } catch {} } +/** + * Scrolls to an element by testID within another + * @param {string} scrollTo - The element to scroll to by testID. + * @param {string} scrollIn - The element to scroll within to by testID. + * @param {number} [speed=350] - The speed at which to scroll + * @param {string} [direction='down'] - The direction of which to scroll + */ +export async function scrollIntoViewByTestId(scrollTo, scrollIn, speed = 350, direction = 'down') { + try { + await waitFor(element(by.id(scrollTo))) + .toBeVisible() + .whileElement(by.id(scrollIn)) + .scroll(speed, direction) + } catch {} +} + export function getDeviceModel() { return device.name.split(/\s(.+)/)[1].replace(/[(]|[)]/g, '') } diff --git a/src/account/utils.ts b/src/account/utils.ts index de47633d408..275772dab55 100644 --- a/src/account/utils.ts +++ b/src/account/utils.ts @@ -1,5 +1,6 @@ import { parsePhoneNumber } from '@celo/phone-utils' -import { ADDRESS_LENGTH } from 'src/exchange/reducer' + +const ADDRESS_LENGTH = 42 // TODO(ACT-1173): see if this can be replaced with a viem helper export const isAddressFormat = (content: string): boolean => { return content.startsWith('0x') && content.length === ADDRESS_LENGTH diff --git a/src/alert/reducer.ts b/src/alert/reducer.ts index 663e5313be6..75945b21d8e 100644 --- a/src/alert/reducer.ts +++ b/src/alert/reducer.ts @@ -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 { @@ -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 { diff --git a/src/analytics/Events.tsx b/src/analytics/Events.tsx index 9d7849886ad..3ac1831b55b 100644 --- a/src/analytics/Events.tsx +++ b/src/analytics/Events.tsx @@ -351,11 +351,7 @@ export enum TransactionEvents { } export enum CeloExchangeEvents { - celo_home_info = 'celo_home_info', - celo_withdraw_completed = 'celo_withdraw_completed', - - celo_chart_tapped = 'celo_chart_tapped', } export enum FiatExchangeEvents { diff --git a/src/analytics/Properties.tsx b/src/analytics/Properties.tsx index 6b164425128..c53468ede10 100644 --- a/src/analytics/Properties.tsx +++ b/src/analytics/Properties.tsx @@ -697,11 +697,9 @@ interface TransactionEventsProperties { } interface CeloExchangeEventsProperties { - [CeloExchangeEvents.celo_home_info]: undefined [CeloExchangeEvents.celo_withdraw_completed]: { amount: string } - [CeloExchangeEvents.celo_chart_tapped]: undefined } interface FiatExchangeEventsProperties { diff --git a/src/analytics/docs.ts b/src/analytics/docs.ts index b4da7694011..3d487fa6ee8 100644 --- a/src/analytics/docs.ts +++ b/src/analytics/docs.ts @@ -360,9 +360,7 @@ export const eventDocs: Record = { [TransactionEvents.transaction_confirmed]: `when a transaction is confirmed by the blockchain`, [TransactionEvents.transaction_error]: `when a transaction submission emits an error (only for contract-kit)`, [TransactionEvents.transaction_exception]: `when a transaction submission throws`, - [CeloExchangeEvents.celo_home_info]: `when the (i) next to Celo Gold price is clicked, launching education (not pictured)`, [CeloExchangeEvents.celo_withdraw_completed]: `when the transaction for the withdrawal is completed`, - [CeloExchangeEvents.celo_chart_tapped]: `when user clicks the chart on exchange screen`, // The CICO landing page accessible from the Settings Menu [FiatExchangeEvents.cico_landing_token_balance]: `User taps to view detailed token balance`, @@ -604,6 +602,8 @@ export const eventDocs: Record = { // [CeloExchangeEvents.celo_withdraw_cancel]: `when ’cancel’ is clicked on the review screen`, // [CeloExchangeEvents.celo_withdraw_confirm]: `when ‘withdraw’ is clicked on the review screen`, // [CeloExchangeEvents.celo_withdraw_error]: `when there's an error on the withdrawal transaction`, + // [CeloExchangeEvents.celo_home_info]: `when the (i) next to Celo Gold price is clicked, launching education (not pictured)`, + // [CeloExchangeEvents.celo_chart_tapped]: `when user clicks the chart on exchange screen`, // [NftEvents.nft_gallery_screen_open]: `When the gallery screen is mounted`, // [PhoneVerificationEvents.phone_verification_input_help_skip]: `when the user presses skip on the help dialog to skip verification`, // [PhoneVerificationEvents.phone_verification_skip]: `when skip is pressed in the phone number input screen`, diff --git a/src/app/reducers.ts b/src/app/reducers.ts index 0ff2ab722e8..a03ed0b168a 100644 --- a/src/app/reducers.ts +++ b/src/app/reducers.ts @@ -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' diff --git a/src/app/saga.ts b/src/app/saga.ts index fe04c71f709..1e40fe1cabc 100644 --- a/src/app/saga.ts +++ b/src/app/saga.ts @@ -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, @@ -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 { @@ -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' diff --git a/src/exchange/CeloNewsFeed.test.tsx b/src/celoNews/CeloNewsFeed.test.tsx similarity index 98% rename from src/exchange/CeloNewsFeed.test.tsx rename to src/celoNews/CeloNewsFeed.test.tsx index fff8bca54c0..32bbefad50b 100644 --- a/src/exchange/CeloNewsFeed.test.tsx +++ b/src/celoNews/CeloNewsFeed.test.tsx @@ -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' diff --git a/src/exchange/CeloNewsFeed.tsx b/src/celoNews/CeloNewsFeed.tsx similarity index 97% rename from src/exchange/CeloNewsFeed.tsx rename to src/celoNews/CeloNewsFeed.tsx index 1afc91e37f7..bed024aaae4 100644 --- a/src/exchange/CeloNewsFeed.tsx +++ b/src/celoNews/CeloNewsFeed.tsx @@ -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' diff --git a/src/exchange/CeloNewsFeedItem.test.tsx b/src/celoNews/CeloNewsFeedItem.test.tsx similarity index 96% rename from src/exchange/CeloNewsFeedItem.test.tsx rename to src/celoNews/CeloNewsFeedItem.test.tsx index eb1e5a20b65..a9d635d6bab 100644 --- a/src/exchange/CeloNewsFeedItem.test.tsx +++ b/src/celoNews/CeloNewsFeedItem.test.tsx @@ -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' diff --git a/src/exchange/CeloNewsFeedItem.tsx b/src/celoNews/CeloNewsFeedItem.tsx similarity index 98% rename from src/exchange/CeloNewsFeedItem.tsx rename to src/celoNews/CeloNewsFeedItem.tsx index 63178d0d178..c895d8badf9 100644 --- a/src/exchange/CeloNewsFeedItem.tsx +++ b/src/celoNews/CeloNewsFeedItem.tsx @@ -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' diff --git a/src/exchange/types.ts b/src/celoNews/types.ts similarity index 100% rename from src/exchange/types.ts rename to src/celoNews/types.ts diff --git a/src/exchange/CeloGoldHistoryChart.test.tsx b/src/exchange/CeloGoldHistoryChart.test.tsx deleted file mode 100644 index 03b06d4f5a4..00000000000 --- a/src/exchange/CeloGoldHistoryChart.test.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { render } from '@testing-library/react-native' -import * as React from 'react' -import 'react-native' -import { Provider } from 'react-redux' -import CeloGoldHistoryChart from 'src/exchange/CeloGoldHistoryChart' -import { createMockStore, getMockI18nProps } from 'test/utils' -import { exchangePriceHistory, mockCeloTokenId, mockTokenBalances } from 'test/values' - -const SAMPLE_BALANCE = '55.00001' - -it('renders without history', () => { - const tree = render( - - - - ) - expect(tree).toMatchSnapshot() -}) - -it('renders while update is in progress', () => { - const localExchangeRatePriceHistory = { ...exchangePriceHistory } - const endDate = new Date('01/01/2020').getTime() - localExchangeRatePriceHistory.lastTimeUpdated = 0 - localExchangeRatePriceHistory.celoGoldExchangeRates = [ - { - exchangeRate: '0.123', - timestamp: endDate, - }, - ] - localExchangeRatePriceHistory.aggregatedExchangeRates = [ - { - exchangeRate: '0.123', - timestamp: endDate, - }, - ] - - const tree = render( - - - - ) - expect(tree).toMatchSnapshot() -}) - -it('renders properly', () => { - const tree = render( - - - - ) - expect(tree).toMatchSnapshot() -}) diff --git a/src/exchange/CeloGoldHistoryChart.tsx b/src/exchange/CeloGoldHistoryChart.tsx deleted file mode 100644 index 20f5f00f254..00000000000 --- a/src/exchange/CeloGoldHistoryChart.tsx +++ /dev/null @@ -1,308 +0,0 @@ -import BigNumber from 'bignumber.js' -import _ from 'lodash' -import React, { useCallback, useState } from 'react' -import { WithTranslation } from 'react-i18next' -import { - ActivityIndicator, - LayoutChangeEvent, - StyleSheet, - Text, - View, - ViewStyle, -} from 'react-native' -import { Circle, G, Line, Text as SvgText } from 'react-native-svg' -import { CeloExchangeEvents } from 'src/analytics/Events' -import ValoraAnalytics from 'src/analytics/ValoraAnalytics' -import { exchangeHistorySelector } from 'src/exchange/reducer' -import { withTranslation } from 'src/i18n' -import { LocalCurrencyCode } from 'src/localCurrency/consts' -import { convertDollarsToLocalAmount } from 'src/localCurrency/convert' -import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' -import { useSelector } from 'src/redux/hooks' -import colors from 'src/styles/colors' -import { Spacing } from 'src/styles/styles' -import variables from 'src/styles/variables' -import { tokensBySymbolSelector } from 'src/tokens/selectors' -import { getLocalCurrencyDisplayValue } from 'src/utils/formatting' -import { formatFeedDate } from 'src/utils/time' -import { VictoryGroup, VictoryLine, VictoryScatter } from 'victory-native' - -const CHART_WIDTH = variables.width -const CHART_HEIGHT = 180 -const CHART_MIN_VERTICAL_RANGE = 0.1 // one cent -const CHART_DOMAIN_PADDING = { y: [30, 30] as [number, number], x: [5, 5] as [number, number] } - -interface OwnProps { - testID?: string - color?: colors - containerStyle?: ViewStyle - chartPadding?: number -} - -type Props = WithTranslation & OwnProps - -// ChartAwareSvgText draws text on the chart with avareness of its edges. -// Example: we want to draw some text at {x:10,y:10} (coordinates of the center). -// The text width is 33px and if draw it right away it will be cuted by the chart edges. -// The component will adjust coordinates to {x: (textWidthInPixels/2), y: 10} -function ChartAwareSvgText({ - position, - x, - y, - value, - chartWidth, -}: { - position: 'top' | 'bottom' - x: number - y: number - value: string - chartWidth: number -}) { - if (position === 'top') { - y = y - 16 - } else if (position === 'bottom') { - y = y + 25 - } - const [adjustedX, setAdjustedX] = useState(x) - const horizontalOffset = variables.contentPadding - const onLayout = useCallback( - ({ - nativeEvent: { - layout: { width }, - }, - }: LayoutChangeEvent) => { - if (Math.abs(width - chartWidth) > 2) { - if (x - width / 2 - horizontalOffset < 0) { - setAdjustedX(width / 2 + horizontalOffset) - } - if (x + width / 2 + horizontalOffset > chartWidth) { - setAdjustedX(chartWidth - width / 2 - horizontalOffset) - } - } - }, - [x] - ) - return ( - - {value} - - ) -} - -function renderPointOnChart( - chartData: Array<{ amount: number | BigNumber; displayValue: string }>, - chartWidth: number, - color: colors -) { - let lowestRateIdx = 0, - highestRateIdx = 0 - chartData.forEach((rate, idx) => { - if (rate.amount > chartData[highestRateIdx].amount) { - highestRateIdx = idx - } - if (rate.amount < chartData[lowestRateIdx].amount) { - lowestRateIdx = idx - } - }) - return ({ datum, x, y }: { x: number; y: number; datum: { _x: number; _y: number } }) => { - const idx = datum._x - const result = [] - switch (idx) { - case 0: - result.push( - - - - - ) - break - - case chartData.length - 1: - result.push( - - - - ) - break - } - switch (idx) { - case highestRateIdx: - result.push( - - ) - break - - case lowestRateIdx: - result.push( - - ) - break - } - - switch (result.length) { - case 0: - return null - case 1: - return result[0] - default: - return <>{result} - } - } -} - -function Loader({ color }: { color: colors }) { - return ( - - - - ) -} -/** - * @deprecated - Use priceHistory/PriceHistoryChart.tsx instead as it handles multiple tokens - */ -function CeloGoldHistoryChart({ - testID, - i18n, - color = colors.goldBrand, - containerStyle, - chartPadding = variables.contentPadding, -}: Props) { - const localCurrencyCode = useSelector(getLocalCurrencyCode) - const displayLocalCurrency = useCallback( - (amount: BigNumber.Value) => - getLocalCurrencyDisplayValue(amount, localCurrencyCode || LocalCurrencyCode.USD, true), - [localCurrencyCode] - ) - const localExchangeRate = useSelector(usdToLocalCurrencyRateSelector) - const dollarsToLocal = useCallback( - (amount: BigNumber.Value | null) => - convertDollarsToLocalAmount(amount, localCurrencyCode ? localExchangeRate : 1), - [localExchangeRate] - ) - const exchangeHistory = useSelector(exchangeHistorySelector) - const tokensBySymbol = useSelector(tokensBySymbolSelector) - - const onTap = useCallback(() => { - ValoraAnalytics.track(CeloExchangeEvents.celo_chart_tapped) - }, []) - - if (!exchangeHistory.aggregatedExchangeRates?.length) { - return - } - - const chartData = exchangeHistory.aggregatedExchangeRates.map((exchangeRate) => { - const localAmount = dollarsToLocal(exchangeRate.exchangeRate) - return { - amount: localAmount ? localAmount.toNumber() : 0, - displayValue: localAmount ? displayLocalCurrency(localAmount) : '', - } - }) - - const currentGoldRateInLocalCurrency = - tokensBySymbol.CGLD?.lastKnownPriceUsd?.toNumber() || - chartData[chartData.length - 1].amount || - null - const oldestGoldRateInLocalCurrency = chartData[0].amount - if (oldestGoldRateInLocalCurrency === null || currentGoldRateInLocalCurrency === null) { - return - } - // We need displayValue to show min/max on the chart. In case the - // current value is min/max we do not need to show it once again, - // therefor displayValue = '' - chartData.push({ - amount: currentGoldRateInLocalCurrency, - displayValue: displayLocalCurrency(currentGoldRateInLocalCurrency), - }) - const RenderPoint = renderPointOnChart(chartData, CHART_WIDTH, color) - - const values = chartData.map((el) => el.amount) - const min = Math.min(...values) - const max = Math.max(...values) - let domain - // ensure that vertical chart range is at least CHART_MIN_VERTICAL_RANGE - if (max - min < CHART_MIN_VERTICAL_RANGE) { - const offset = CHART_MIN_VERTICAL_RANGE - (max - min) / 2 - domain = { - y: [min - offset, max + offset] as [number, number], - x: [0, chartData.length - 1] as [number, number], - } - } - const latestExchangeRate = _.last(exchangeHistory.aggregatedExchangeRates)! - - return ( - - el.amount)} - domain={domain} - > - {/* - // @ts-ignore */} - } /> - - - - - {formatFeedDate(latestExchangeRate.timestamp - exchangeHistory.range, i18n)} - - {formatFeedDate(latestExchangeRate.timestamp, i18n)} - - - ) -} - -const styles = StyleSheet.create({ - container: { - marginBottom: Spacing.Thick24, - }, - loader: { - width: CHART_WIDTH, - height: CHART_HEIGHT + 37.5, - alignItems: 'center', - justifyContent: 'center', - }, - timeframe: { - color: colors.gray3, - fontSize: 16, - }, - range: { - marginTop: variables.contentPadding, - justifyContent: 'space-between', - flexDirection: 'row', - }, -}) - -export default withTranslation()(CeloGoldHistoryChart) diff --git a/src/exchange/__snapshots__/CeloGoldHistoryChart.test.tsx.snap b/src/exchange/__snapshots__/CeloGoldHistoryChart.test.tsx.snap deleted file mode 100644 index a33cc533dec..00000000000 --- a/src/exchange/__snapshots__/CeloGoldHistoryChart.test.tsx.snap +++ /dev/null @@ -1,406 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders properly 1`] = ` - - - - - - - - - - - ₱0.00 - - - ₱1.30 - - - - - - - - - - - - - - - - - - - - - - - Oct 4 - - - Nov 3 - - - -`; - -exports[`renders while update is in progress 1`] = ` - - - - - - - - - - - ₱0.16 - - - - - - - - - - - - - - - - - - - - - - - Dec 2 - - - Jan 1 - - - -`; - -exports[`renders without history 1`] = ` - - - -`; diff --git a/src/exchange/actions.ts b/src/exchange/actions.ts deleted file mode 100644 index f567caca1a1..00000000000 --- a/src/exchange/actions.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ExchangeRate } from 'src/exchange/reducer' - -export enum Actions { - UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY = 'EXCHANGE/UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY', -} - -export interface UpdateCeloGoldExchangeRateHistory { - type: Actions.UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY - timestamp: number - exchangeRates: ExchangeRate[] -} - -export const updateCeloGoldExchangeRateHistory = ( - exchangeRates: ExchangeRate[], - timestamp: number -): UpdateCeloGoldExchangeRateHistory => ({ - type: Actions.UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY, - exchangeRates, - timestamp, -}) - -export type ActionTypes = UpdateCeloGoldExchangeRateHistory diff --git a/src/exchange/reducer.ts b/src/exchange/reducer.ts deleted file mode 100644 index 1bdd03b2624..00000000000 --- a/src/exchange/reducer.ts +++ /dev/null @@ -1,117 +0,0 @@ -import _ from 'lodash' -import { Actions, ActionTypes } from 'src/exchange/actions' -import { getRehydratePayload, REHYDRATE, RehydrateAction } from 'src/redux/persist-helper' -import { RootState } from 'src/redux/reducers' -import { Currency } from 'src/utils/currencies' - -export const MAX_HISTORY_RETENTION = 30 * 24 * 3600 * 1000 // (ms) ~ 30 days -export const ADDRESS_LENGTH = 42 - -export interface ExchangeRate { - exchangeRate: string - timestamp: number -} - -export type ExchangeRates = Record> - -interface State { - history: { - // TODO this should be remove once we have aggregation on - // blockchain api side - celoGoldExchangeRates: ExchangeRate[] - aggregatedExchangeRates: ExchangeRate[] - granularity: number - range: number - lastTimeUpdated: number - } -} - -export const initialState = { - history: { - celoGoldExchangeRates: [], - aggregatedExchangeRates: [], - granularity: 60, - range: 30 * 24 * 60 * 60 * 1000, // 30 days - lastTimeUpdated: 0, - }, -} - -export const exchangeHistorySelector = (state: RootState) => state.exchange.history - -function aggregateExchangeRates( - celoGoldExchangeRates: ExchangeRate[], - granularity: number, - range: number -): ExchangeRate[] { - if (!celoGoldExchangeRates.length) { - return [] - } - function calculateGroup(exchangeRate: ExchangeRate) { - return Math.floor(exchangeRate.timestamp / (range / granularity)) - } - const groupedExchangeHistory = _.groupBy(celoGoldExchangeRates, calculateGroup) - const latestExchangeRate = celoGoldExchangeRates[celoGoldExchangeRates.length - 1] - const latestGroup = calculateGroup(latestExchangeRate) - - return _.range(Math.min(granularity - 1, Object.keys(groupedExchangeHistory).length), 0, -1).map( - (i) => { - const group = groupedExchangeHistory[latestGroup - i + 1] - return { - exchangeRate: group ? _.meanBy(group, (er) => parseFloat(er.exchangeRate)).toString() : '0', - timestamp: _.first(group)?.timestamp ?? 0, - } - } - ) -} - -export const historyReducer = ( - state: State['history'] | undefined = initialState.history, - action: ActionTypes -): State['history'] => { - switch (action.type) { - case Actions.UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY: - const celoGoldExchangeRates = [ - ...state.celoGoldExchangeRates, - ...action.exchangeRates, - ].filter((er) => er.timestamp > action.timestamp - MAX_HISTORY_RETENTION) - return { - ...state, - celoGoldExchangeRates, - aggregatedExchangeRates: aggregateExchangeRates( - celoGoldExchangeRates, - state.granularity, - state.range - ), - lastTimeUpdated: action.timestamp, - } - default: - return state - } -} - -export const reducer = ( - state: State | undefined = initialState, - action: ActionTypes | RehydrateAction -): State => { - switch (action.type) { - case REHYDRATE: { - // Ignore some persisted properties - const persisted = getRehydratePayload(action, 'exchange') - return { - ...state, - ...persisted, - history: { - ...initialState.history, - ...persisted.history, - }, - } - } - case Actions.UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY: - return { - ...state, - history: historyReducer(state.history, action), - } - default: - return state - } -} diff --git a/src/firebase/saga.ts b/src/firebase/saga.ts index bd804f82078..1b8e68ab3de 100644 --- a/src/firebase/saga.ts +++ b/src/firebase/saga.ts @@ -1,14 +1,10 @@ import { sleep } from '@celo/utils/lib/async' import firebase from '@react-native-firebase/app' -import { FirebaseDatabaseTypes } from '@react-native-firebase/database' -import { eventChannel } from 'redux-saga' import { handleUpdateAccountRegistration } from 'src/account/saga' import { showError } from 'src/alert/actions' import { ErrorMessages } from 'src/app/ErrorMessages' import { Actions as AppActions } from 'src/app/actions' import { FIREBASE_ENABLED, isE2EEnv } from 'src/config' -import { updateCeloGoldExchangeRateHistory } from 'src/exchange/actions' -import { ExchangeRate, MAX_HISTORY_RETENTION, exchangeHistorySelector } from 'src/exchange/reducer' import { Actions, firebaseAuthorized } from 'src/firebase/actions' import { checkInitialNotification, @@ -21,11 +17,9 @@ import { setLanguage } from 'src/i18n/slice' import Logger from 'src/utils/Logger' import { safely } from 'src/utils/safely' import { getAccount } from 'src/web3/saga' -import { call, cancelled, put, select, spawn, take, takeEvery, takeLatest } from 'typed-redux-saga' +import { call, put, spawn, takeEvery, takeLatest } from 'typed-redux-saga' const TAG = 'firebase/saga' -const EXCHANGE_RATES = 'exchangeRates' -const VALUE_CHANGE_HOOK = 'value' const FIREBASE_CONNECT_RETRIES = 3 export function* waitForFirebaseAuth() { @@ -80,84 +74,9 @@ export function* watchLanguage() { yield* takeEvery(setLanguage.type, safely(syncLanguageSelection)) } -function celoGoldExchangeRateHistoryChannel(lastTimeUpdated: number) { - const errorCallback = (error: Error) => { - Logger.warn(TAG, error.toString()) - } - - const now = Date.now() - // timestamp + 1 is used because .startAt is inclusive - const startAt = Math.max(lastTimeUpdated + 1, now - MAX_HISTORY_RETENTION) - - return eventChannel((emit: any) => { - const singleItemEmitter = (snapshot: FirebaseDatabaseTypes.DataSnapshot) => { - emit([snapshot.val()]) - } - const listenForNewElements = (newElementsStartAt: number) => { - firebase - .database() - .ref(`${EXCHANGE_RATES}/cGLD/cUSD`) - .orderByChild('timestamp') - .startAt(newElementsStartAt) - .on('child_added', singleItemEmitter, errorCallback) - } - const fullListEmitter = (snapshot: FirebaseDatabaseTypes.DataSnapshot) => { - const result: ExchangeRate[] = [] - snapshot.forEach((childSnapshot: FirebaseDatabaseTypes.DataSnapshot) => { - result.push(childSnapshot.val()) - return undefined - }) - if (result.length) { - emit(result) - listenForNewElements(result[result.length - 1].timestamp + 1) - } else { - listenForNewElements(startAt) - } - } - - firebase - .database() - .ref(`${EXCHANGE_RATES}/cGLD/cUSD`) - .orderByChild('timestamp') - .startAt(startAt) - .once(VALUE_CHANGE_HOOK, fullListEmitter, errorCallback) - .catch((error) => { - Logger.error(TAG, 'Error while fetching exchange rates', error) - }) - - return () => { - firebase.database().ref(`${EXCHANGE_RATES}/cGLD/cUSD`).off() - } - }) -} - -export function* subscribeToCeloGoldExchangeRateHistory() { - yield* call(waitForFirebaseAuth) - const history = yield* select(exchangeHistorySelector) - const channel = yield* call(celoGoldExchangeRateHistoryChannel, history.lastTimeUpdated) - try { - while (true) { - const exchangeRates = (yield* take(channel)) as ExchangeRate[] - const now = Date.now() - yield* put(updateCeloGoldExchangeRateHistory(exchangeRates, now)) - } - } catch (error) { - Logger.error( - `${TAG}@subscribeToCeloGoldExchangeRateHistory`, - 'Failed to subscribe to celo gold exchange rate history', - error - ) - } finally { - if (yield* cancelled()) { - channel.close() - } - } -} - export function* firebaseSaga() { yield* spawn(initializeFirebase) yield* spawn(watchLanguage) - yield* spawn(subscribeToCeloGoldExchangeRateHistory) yield* takeLatest(AppActions.APP_MOUNTED, safely(watchFirebaseNotificationChannel)) yield* takeLatest(AppActions.APP_MOUNTED, safely(checkInitialNotification)) } diff --git a/src/redux/migrations.test.ts b/src/redux/migrations.test.ts index 3fa39fb038b..acc10e4dea0 100644 --- a/src/redux/migrations.test.ts +++ b/src/redux/migrations.test.ts @@ -1,8 +1,7 @@ import BigNumber from 'bignumber.js' import _ from 'lodash' import { FinclusiveKycStatus } from 'src/account/reducer' -import { initialState as exchangeInitialState } from 'src/exchange/reducer' -import { migrations } from 'src/redux/migrations' +import { exchangeInitialState, migrations } from 'src/redux/migrations' import { Network, NetworkId, @@ -83,11 +82,11 @@ import { mockInvitableRecipient, mockInvitableRecipient2, mockPositions, - mockShortcuts, + mockPositionsLegacy, mockRecipient, mockRecipient2, + mockShortcuts, mockShortcutsLegacy, - mockPositionsLegacy, } from 'test/values' describe('Redux persist migrations', () => { diff --git a/src/redux/migrations.ts b/src/redux/migrations.ts index cc3a8f4a998..332e8eb1492 100644 --- a/src/redux/migrations.ts +++ b/src/redux/migrations.ts @@ -3,7 +3,6 @@ import { FinclusiveKycStatus, RecoveryPhraseInOnboardingStatus } from 'src/accou import { MultichainBetaStatus } from 'src/app/actions' import { DEFAULT_SENTRY_NETWORK_ERRORS, DEFAULT_SENTRY_TRACES_SAMPLE_RATE } from 'src/config' import { Dapp } from 'src/dapps/types' -import { initialState as exchangeInitialState } from 'src/exchange/reducer' import { CachedQuoteParams, SendingFiatAccountStatus } from 'src/fiatconnect/slice' import { REMOTE_CONFIG_VALUES_DEFAULTS } from 'src/firebase/remoteConfigValuesDefaults' import { AddressToDisplayNameType } from 'src/identity/reducer' @@ -41,6 +40,16 @@ export function updateCachedQuoteParams(cachedQuoteParams: { const DEFAULT_DAILY_PAYMENT_LIMIT_CUSD_LEGACY = 1000 +export const exchangeInitialState = { + history: { + celoGoldExchangeRates: [], + aggregatedExchangeRates: [], + granularity: 60, + range: 30 * 24 * 60 * 60 * 1000, // 30 days + lastTimeUpdated: 0, + }, +} + export const migrations = { 0: (state: any) => { const e164NumberToAddressOld = state.identity.e164NumberToAddress @@ -1765,4 +1774,7 @@ export const migrations = { pointsHistory: [], }, }), + 211: (state: any) => ({ + ...(_.omit(state, 'exchange') as any), + }), } diff --git a/src/redux/reducers.ts b/src/redux/reducers.ts index 6da0d80bcc1..63469cd5270 100644 --- a/src/redux/reducers.ts +++ b/src/redux/reducers.ts @@ -7,7 +7,6 @@ import { appReducer as app } from 'src/app/reducers' import superchargeReducer from 'src/consumerIncentives/slice' import dappsReducer from 'src/dapps/slice' import { escrowReducer as escrow } from 'src/escrow/reducer' -import { reducer as exchange } from 'src/exchange/reducer' import { reducer as fees } from 'src/fees/reducer' import { reducer as fiatExchanges } from 'src/fiatExchanges/reducer' import fiatConnectReducer from 'src/fiatconnect/slice' @@ -20,6 +19,7 @@ import keylessBackupReducer from 'src/keylessBackup/slice' import { reducer as localCurrency } from 'src/localCurrency/reducer' import { reducer as networkInfo } from 'src/networkInfo/reducer' import nftsReducer from 'src/nfts/slice' +import pointsReducer from 'src/points/slice' import positionsReducer from 'src/positions/slice' import priceHistoryReducer from 'src/priceHistory/slice' import { recipientsReducer as recipients } from 'src/recipients/reducer' @@ -29,7 +29,6 @@ import tokenReducer from 'src/tokens/slice' import { reducer as transactions } from 'src/transactions/reducer' import { reducer as walletConnect } from 'src/walletConnect/reducer' import { reducer as web3 } from 'src/web3/reducer' -import pointsReducer from 'src/points/slice' const appReducer = combineReducers({ app, @@ -38,7 +37,6 @@ const appReducer = combineReducers({ alert, send, home, - exchange, transactions, web3, identity, diff --git a/src/redux/sagas.ts b/src/redux/sagas.ts index dde1cdf031a..e2271112306 100644 --- a/src/redux/sagas.ts +++ b/src/redux/sagas.ts @@ -18,10 +18,9 @@ import { superchargeSaga } from 'src/consumerIncentives/saga' import { dappKitSaga } from 'src/dappkit/dappkit' import { dappsSaga } from 'src/dapps/saga' import { escrowSaga } from 'src/escrow/saga' -import { Actions as ExchangeActions } from 'src/exchange/actions' import { feesSaga } from 'src/fees/saga' -import { fiatConnectSaga } from 'src/fiatconnect/saga' import { fiatExchangesSaga } from 'src/fiatExchanges/saga' +import { fiatConnectSaga } from 'src/fiatconnect/saga' import { firebaseSaga } from 'src/firebase/saga' import { homeSaga } from 'src/home/saga' import { i18nSaga } from 'src/i18n/saga' @@ -33,6 +32,7 @@ import { keylessBackupSaga } from 'src/keylessBackup/saga' import { localCurrencySaga } from 'src/localCurrency/saga' import { networkInfoSaga } from 'src/networkInfo/saga' import { nftsSaga } from 'src/nfts/saga' +import { pointsSaga } from 'src/points/saga' import { positionsSaga } from 'src/positions/saga' import { priceHistorySaga } from 'src/priceHistory/saga' import { setPhoneRecipientCache, updateValoraRecipientCache } from 'src/recipients/reducer' @@ -43,19 +43,17 @@ import { swapSaga } from 'src/swap/saga' import { tokensSaga } from 'src/tokens/saga' import { Actions as TransactionActions } from 'src/transactions/actions' import { transactionSaga } from 'src/transactions/saga' -import { checkAccountExistenceSaga } from 'src/utils/accountChecker' import Logger from 'src/utils/Logger' +import { checkAccountExistenceSaga } from 'src/utils/accountChecker' import { walletConnectSaga } from 'src/walletConnect/saga' import { Actions as Web3Actions } from 'src/web3/actions' import { web3Saga } from 'src/web3/saga' -import { pointsSaga } from 'src/points/saga' import { call, select, spawn, take, takeEvery } from 'typed-redux-saga' const loggerBlocklist = [ REHYDRATE, AppActions.PHONE_NUMBER_VERIFICATION_COMPLETED, AccountActions.SET_PHONE_NUMBER, - ExchangeActions.UPDATE_CELO_GOLD_EXCHANGE_RATE_HISTORY, // Not private, just noisy ImportActions.IMPORT_BACKUP_PHRASE, setPhoneRecipientCache.toString(), updateValoraRecipientCache.toString(), diff --git a/src/redux/store.test.ts b/src/redux/store.test.ts index 56d5b708e7e..bdaed07fd14 100644 --- a/src/redux/store.test.ts +++ b/src/redux/store.test.ts @@ -98,7 +98,7 @@ describe('store state', () => { { "_persist": { "rehydrated": true, - "version": 210, + "version": 211, }, "account": { "acceptedTerms": false, @@ -191,15 +191,6 @@ describe('store state', () => { "isReclaiming": false, "sentEscrowedPayments": [], }, - "exchange": { - "history": { - "aggregatedExchangeRates": [], - "celoGoldExchangeRates": [], - "granularity": 60, - "lastTimeUpdated": 0, - "range": 2592000000, - }, - }, "fees": { "estimates": {}, }, diff --git a/src/redux/store.ts b/src/redux/store.ts index 48ae87d249f..f26782ecc57 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -21,7 +21,7 @@ const persistConfig: PersistConfig = { key: 'root', // default is -1, increment as we make migrations // See https://github.com/valora-inc/wallet/tree/main/WALLET.md#redux-state-migration - version: 210, + version: 211, keyPrefix: `reduxStore-`, // the redux-persist default is `persist:` which doesn't work with some file systems. storage: FSStorage(), blacklist: ['networkInfo', 'alert', 'imports', 'keylessBackup', 'jumpstart'], diff --git a/src/statsig/constants.ts b/src/statsig/constants.ts index c8d6e234fb8..5f9d8e931e1 100644 --- a/src/statsig/constants.ts +++ b/src/statsig/constants.ts @@ -19,7 +19,6 @@ export const FeatureGates = { [StatsigFeatureGates.SHOW_MULTICHAIN_BETA_SCREEN]: false, [StatsigFeatureGates.SHOW_BETA_TAG]: false, [StatsigFeatureGates.SAVE_CONTACTS]: false, - [StatsigFeatureGates.USE_PRICE_HISTORY_FROM_BLOCKCHAIN_API]: false, [StatsigFeatureGates.SHOW_GET_STARTED]: false, [StatsigFeatureGates.CLEVERTAP_INBOX]: false, [StatsigFeatureGates.SHOW_SWAP_TOKEN_FILTERS]: false, diff --git a/src/statsig/types.ts b/src/statsig/types.ts index 93b1037064b..0df14aa68cb 100644 --- a/src/statsig/types.ts +++ b/src/statsig/types.ts @@ -21,7 +21,6 @@ export enum StatsigFeatureGates { SHOW_MULTICHAIN_BETA_SCREEN = 'show_multichain_beta_screen', SHOW_BETA_TAG = 'show_beta_tag', SAVE_CONTACTS = 'save_contacts', - USE_PRICE_HISTORY_FROM_BLOCKCHAIN_API = 'use_price_history_from_blockchain_api', SHOW_GET_STARTED = 'show_get_started', CLEVERTAP_INBOX = 'clevertap_inbox', SHOW_SWAP_TOKEN_FILTERS = 'show_swap_token_filters', diff --git a/src/tokens/TokenDetails.test.tsx b/src/tokens/TokenDetails.test.tsx index ea7c128ea44..d93ffed4525 100644 --- a/src/tokens/TokenDetails.test.tsx +++ b/src/tokens/TokenDetails.test.tsx @@ -13,7 +13,6 @@ import { ONE_DAY_IN_MILLIS } from 'src/utils/time' import MockedNavigator from 'test/MockedNavigator' import { createMockStore } from 'test/utils' import { - exchangePriceHistory, mockCeloTokenId, mockPoofTokenId, mockTestTokenTokenId, @@ -178,26 +177,7 @@ describe('TokenDetails', () => { expect(queryByText('tokenDetails.priceUnavailable')).toBeFalsy() }) - it('renders chart and news feed if token is native (celo) using firebase', () => { - jest.mocked(getFeatureGate).mockReturnValue(false) // Use old prices from firebase - const store = createMockStore({ - exchange: { - history: exchangePriceHistory, - }, - }) - - const { getByTestId, queryByText } = render( - - - - ) - - expect(getByTestId('TokenDetails/Chart')).toBeTruthy() - expect(queryByText('celoNews.headerTitle')).toBeTruthy() - }) - it('renders chart loader using blockchain API', () => { - jest.mocked(getFeatureGate).mockReturnValue(true) // Use new prices from blockchain API const store = createMockStore({ priceHistory: { [mockCeloTokenId]: { diff --git a/src/tokens/TokenDetails.tsx b/src/tokens/TokenDetails.tsx index 8f6b072c7e9..574a0315f3e 100644 --- a/src/tokens/TokenDetails.tsx +++ b/src/tokens/TokenDetails.tsx @@ -6,6 +6,7 @@ import { SafeAreaView } from 'react-native-safe-area-context' import { AssetsEvents } from 'src/analytics/Events' import { TokenProperties } from 'src/analytics/Properties' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' +import CeloNewsFeed from 'src/celoNews/CeloNewsFeed' import BackButton from 'src/components/BackButton' import { BottomSheetRefType } from 'src/components/BottomSheet' import Button, { BtnSizes } from 'src/components/Button' @@ -14,8 +15,6 @@ import TokenDisplay from 'src/components/TokenDisplay' import TokenIcon, { IconSize } from 'src/components/TokenIcon' import Touchable from 'src/components/Touchable' import CustomHeader from 'src/components/header/CustomHeader' -import CeloGoldHistoryChart from 'src/exchange/CeloGoldHistoryChart' -import CeloNewsFeed from 'src/exchange/CeloNewsFeed' import { CICOFlow } from 'src/fiatExchanges/utils' import ArrowRightThick from 'src/icons/ArrowRightThick' import DataDown from 'src/icons/DataDown' @@ -34,8 +33,6 @@ import { StackParamList } from 'src/navigator/types' import PriceHistoryChart from 'src/priceHistory/PriceHistoryChart' import { useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' -import { getFeatureGate } from 'src/statsig' -import { StatsigFeatureGates } from 'src/statsig/types' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' @@ -70,14 +67,11 @@ export default function TokenDetailsScreen({ route }: Props) { const actions = useActions(token) const tokenDetailsMoreActionsBottomSheetRef = useRef(null) const localCurrencySymbol = useSelector(getLocalCurrencySymbol) - const usePriceHistoryFromBlockchainApi = getFeatureGate( - StatsigFeatureGates.USE_PRICE_HISTORY_FROM_BLOCKCHAIN_API - ) return ( } /> - + {!token.isStableCoin && } - {token.isNative && usePriceHistoryFromBlockchainApi ? ( + {token.isNative && ( - ) : ( - token.tokenId === networkConfig.celoTokenId && ( - - ) )} { switch (action.type) { case REHYDRATE: { diff --git a/test/RootStateSchema.json b/test/RootStateSchema.json index 82d3e2c2316..9b10c73d4a9 100644 --- a/test/RootStateSchema.json +++ b/test/RootStateSchema.json @@ -1235,22 +1235,6 @@ ], "type": "object" }, - "ExchangeRate": { - "additionalProperties": false, - "properties": { - "exchangeRate": { - "type": "string" - }, - "timestamp": { - "type": "number" - } - }, - "required": [ - "exchangeRate", - "timestamp" - ], - "type": "object" - }, "Fee": { "additionalProperties": false, "properties": { @@ -3593,121 +3577,6 @@ "type": "object" }, "State_10": { - "additionalProperties": false, - "properties": { - "acceptedTerms": { - "type": "boolean" - }, - "accountCreationTime": { - "type": "number" - }, - "accountToRecoverFromStoreWipe": { - "type": "string" - }, - "backupCompleted": { - "type": "boolean" - }, - "celoEducationCompleted": { - "type": "boolean" - }, - "choseToRestoreAccount": { - "type": "boolean" - }, - "cloudBackupCompleted": { - "type": "boolean" - }, - "contactDetails": { - "$ref": "#/definitions/UserContactDetails" - }, - "defaultCountryCode": { - "type": [ - "null", - "string" - ] - }, - "devModeActive": { - "type": "boolean" - }, - "devModeClickCount": { - "type": "number" - }, - "dismissedGetVerified": { - "type": "boolean" - }, - "dismissedGoldEducation": { - "type": "boolean" - }, - "dismissedKeepSupercharging": { - "type": "boolean" - }, - "dismissedStartSupercharging": { - "type": "boolean" - }, - "e164PhoneNumber": { - "type": [ - "null", - "string" - ] - }, - "hasMigratedToNewBip39": { - "type": "boolean" - }, - "name": { - "type": [ - "null", - "string" - ] - }, - "photosNUXClicked": { - "type": "boolean" - }, - "pictureUri": { - "type": [ - "null", - "string" - ] - }, - "pincodeType": { - "$ref": "#/definitions/PincodeType" - }, - "profileUploaded": { - "type": "boolean" - }, - "recoveringFromStoreWipe": { - "type": "boolean" - }, - "recoveryPhraseInOnboardingStatus": { - "$ref": "#/definitions/RecoveryPhraseInOnboardingStatus" - }, - "startOnboardingTime": { - "type": "number" - } - }, - "required": [ - "acceptedTerms", - "accountCreationTime", - "backupCompleted", - "celoEducationCompleted", - "cloudBackupCompleted", - "contactDetails", - "defaultCountryCode", - "devModeActive", - "devModeClickCount", - "dismissedGetVerified", - "dismissedGoldEducation", - "dismissedKeepSupercharging", - "dismissedStartSupercharging", - "e164PhoneNumber", - "hasMigratedToNewBip39", - "name", - "photosNUXClicked", - "pictureUri", - "pincodeType", - "recoveryPhraseInOnboardingStatus" - ], - "type": "object" - }, - "State_11": { "additionalProperties": false, "properties": { "isReclaiming": { @@ -3726,7 +3595,7 @@ ], "type": "object" }, - "State_12": { + "State_11": { "additionalProperties": false, "properties": { "estimates": { @@ -3738,7 +3607,7 @@ ], "type": "object" }, - "State_13": { + "State_12": { "additionalProperties": false, "properties": { "coinbasePaySenders": { @@ -3775,7 +3644,7 @@ ], "type": "object" }, - "State_14": { + "State_13": { "additionalProperties": false, "properties": { "error": { @@ -3898,7 +3767,7 @@ ], "type": "object" }, - "State_15": { + "State_14": { "additionalProperties": false, "properties": { "isImportingWallet": { @@ -3910,7 +3779,7 @@ ], "type": "object" }, - "State_16": { + "State_15": { "additionalProperties": false, "properties": { "providerLogos": { @@ -3926,7 +3795,7 @@ ], "type": "object" }, - "State_17": { + "State_16": { "additionalProperties": false, "properties": { "pendingActions": { @@ -3955,7 +3824,7 @@ ], "type": "object" }, - "State_18": { + "State_17": { "additionalProperties": false, "properties": { "error": { @@ -3975,7 +3844,7 @@ ], "type": "object" }, - "State_19": { + "State_18": { "additionalProperties": false, "properties": { "availableRewards": { @@ -4010,27 +3879,7 @@ ], "type": "object" }, - "State_2": { - "additionalProperties": false, - "properties": { - "connected": { - "type": "boolean" - }, - "rehydrated": { - "type": "boolean" - }, - "userLocationData": { - "$ref": "#/definitions/UserLocationData" - } - }, - "required": [ - "connected", - "rehydrated", - "userLocationData" - ], - "type": "object" - }, - "State_20": { + "State_19": { "additionalProperties": false, "properties": { "activeDapp": { @@ -4110,7 +3959,27 @@ ], "type": "object" }, - "State_21": { + "State_2": { + "additionalProperties": false, + "properties": { + "connected": { + "type": "boolean" + }, + "rehydrated": { + "type": "boolean" + }, + "userLocationData": { + "$ref": "#/definitions/UserLocationData" + } + }, + "required": [ + "connected", + "rehydrated", + "userLocationData" + ], + "type": "object" + }, + "State_20": { "additionalProperties": false, "properties": { "attemptReturnUserFlowLoading": { @@ -4265,7 +4134,7 @@ ], "type": "object" }, - "State_22": { + "State_21": { "additionalProperties": false, "properties": { "currentSwap": { @@ -4296,7 +4165,7 @@ ], "type": "object" }, - "State_23": { + "State_22": { "additionalProperties": false, "properties": { "positions": { @@ -4337,7 +4206,7 @@ ], "type": "object" }, - "State_24": { + "State_23": { "additionalProperties": false, "properties": { "backupStatus": { @@ -4378,7 +4247,7 @@ ], "type": "object" }, - "State_26": { + "State_25": { "additionalProperties": { "additionalProperties": false, "properties": { @@ -4400,7 +4269,7 @@ }, "type": "object" }, - "State_27": { + "State_26": { "additionalProperties": false, "properties": { "claimStatus": { @@ -4437,7 +4306,7 @@ ], "type": "object" }, - "State_28": { + "State_27": { "additionalProperties": false, "properties": { "getHistoryStatus": { @@ -4620,49 +4489,6 @@ "type": "object" }, "State_6": { - "additionalProperties": false, - "properties": { - "history": { - "additionalProperties": false, - "properties": { - "aggregatedExchangeRates": { - "items": { - "$ref": "#/definitions/ExchangeRate" - }, - "type": "array" - }, - "celoGoldExchangeRates": { - "items": { - "$ref": "#/definitions/ExchangeRate" - }, - "type": "array" - }, - "granularity": { - "type": "number" - }, - "lastTimeUpdated": { - "type": "number" - }, - "range": { - "type": "number" - } - }, - "required": [ - "aggregatedExchangeRates", - "celoGoldExchangeRates", - "granularity", - "lastTimeUpdated", - "range" - ], - "type": "object" - } - }, - "required": [ - "history" - ], - "type": "object" - }, - "State_7": { "additionalProperties": false, "properties": { "inviteTransactions": { @@ -4693,7 +4519,7 @@ ], "type": "object" }, - "State_8": { + "State_7": { "additionalProperties": false, "properties": { "account": { @@ -4733,7 +4559,7 @@ ], "type": "object" }, - "State_9": { + "State_8": { "additionalProperties": false, "properties": { "addressToDataEncryptionKey": { @@ -4796,6 +4622,121 @@ ], "type": "object" }, + "State_9": { + "additionalProperties": false, + "properties": { + "acceptedTerms": { + "type": "boolean" + }, + "accountCreationTime": { + "type": "number" + }, + "accountToRecoverFromStoreWipe": { + "type": "string" + }, + "backupCompleted": { + "type": "boolean" + }, + "celoEducationCompleted": { + "type": "boolean" + }, + "choseToRestoreAccount": { + "type": "boolean" + }, + "cloudBackupCompleted": { + "type": "boolean" + }, + "contactDetails": { + "$ref": "#/definitions/UserContactDetails" + }, + "defaultCountryCode": { + "type": [ + "null", + "string" + ] + }, + "devModeActive": { + "type": "boolean" + }, + "devModeClickCount": { + "type": "number" + }, + "dismissedGetVerified": { + "type": "boolean" + }, + "dismissedGoldEducation": { + "type": "boolean" + }, + "dismissedKeepSupercharging": { + "type": "boolean" + }, + "dismissedStartSupercharging": { + "type": "boolean" + }, + "e164PhoneNumber": { + "type": [ + "null", + "string" + ] + }, + "hasMigratedToNewBip39": { + "type": "boolean" + }, + "name": { + "type": [ + "null", + "string" + ] + }, + "photosNUXClicked": { + "type": "boolean" + }, + "pictureUri": { + "type": [ + "null", + "string" + ] + }, + "pincodeType": { + "$ref": "#/definitions/PincodeType" + }, + "profileUploaded": { + "type": "boolean" + }, + "recoveringFromStoreWipe": { + "type": "boolean" + }, + "recoveryPhraseInOnboardingStatus": { + "$ref": "#/definitions/RecoveryPhraseInOnboardingStatus" + }, + "startOnboardingTime": { + "type": "number" + } + }, + "required": [ + "acceptedTerms", + "accountCreationTime", + "backupCompleted", + "celoEducationCompleted", + "cloudBackupCompleted", + "contactDetails", + "defaultCountryCode", + "devModeActive", + "devModeClickCount", + "dismissedGetVerified", + "dismissedGoldEducation", + "dismissedKeepSupercharging", + "dismissedStartSupercharging", + "e164PhoneNumber", + "hasMigratedToNewBip39", + "name", + "photosNUXClicked", + "pictureUri", + "pincodeType", + "recoveryPhraseInOnboardingStatus" + ], + "type": "object" + }, "Status": { "enum": [ "error", @@ -6308,7 +6249,7 @@ "$ref": "#/definitions/PersistState" }, "account": { - "$ref": "#/definitions/State_10" + "$ref": "#/definitions/State_9" }, "alert": { "$ref": "#/definitions/State_3" @@ -6317,22 +6258,19 @@ "$ref": "#/definitions/State" }, "dapps": { - "$ref": "#/definitions/State_20" + "$ref": "#/definitions/State_19" }, "escrow": { - "$ref": "#/definitions/State_11" - }, - "exchange": { - "$ref": "#/definitions/State_6" + "$ref": "#/definitions/State_10" }, "fees": { - "$ref": "#/definitions/State_12" + "$ref": "#/definitions/State_11" }, "fiatConnect": { - "$ref": "#/definitions/State_21" + "$ref": "#/definitions/State_20" }, "fiatExchanges": { - "$ref": "#/definitions/State_16" + "$ref": "#/definitions/State_15" }, "home": { "$ref": "#/definitions/State_5" @@ -6341,19 +6279,19 @@ "$ref": "#/definitions/State_1" }, "identity": { - "$ref": "#/definitions/State_9" + "$ref": "#/definitions/State_8" }, "imports": { - "$ref": "#/definitions/State_15" + "$ref": "#/definitions/State_14" }, "jumpstart": { - "$ref": "#/definitions/State_27" + "$ref": "#/definitions/State_26" }, "keylessBackup": { - "$ref": "#/definitions/State_24" + "$ref": "#/definitions/State_23" }, "localCurrency": { - "$ref": "#/definitions/State_14" + "$ref": "#/definitions/State_13" }, "networkInfo": { "$ref": "#/definitions/State_2" @@ -6385,37 +6323,37 @@ "type": "object" }, "points": { - "$ref": "#/definitions/State_28" + "$ref": "#/definitions/State_27" }, "positions": { - "$ref": "#/definitions/State_23" + "$ref": "#/definitions/State_22" }, "priceHistory": { - "$ref": "#/definitions/State_26" + "$ref": "#/definitions/State_25" }, "recipients": { - "$ref": "#/definitions/State_13" + "$ref": "#/definitions/State_12" }, "send": { "$ref": "#/definitions/State_4" }, "supercharge": { - "$ref": "#/definitions/State_19" + "$ref": "#/definitions/State_18" }, "swap": { - "$ref": "#/definitions/State_22" + "$ref": "#/definitions/State_21" }, "tokens": { - "$ref": "#/definitions/State_18" + "$ref": "#/definitions/State_17" }, "transactions": { - "$ref": "#/definitions/State_7" + "$ref": "#/definitions/State_6" }, "walletConnect": { - "$ref": "#/definitions/State_17" + "$ref": "#/definitions/State_16" }, "web3": { - "$ref": "#/definitions/State_8" + "$ref": "#/definitions/State_7" } }, "required": [ @@ -6425,7 +6363,6 @@ "app", "dapps", "escrow", - "exchange", "fees", "fiatConnect", "fiatExchanges", diff --git a/test/schemas.ts b/test/schemas.ts index cec52b5314b..13ccb591002 100644 --- a/test/schemas.ts +++ b/test/schemas.ts @@ -3286,6 +3286,14 @@ export const v210Schema = { }, } +export const v211Schema = { + ..._.omit(v210Schema, 'exchange'), + _persist: { + ...v210Schema._persist, + version: 211, + }, +} + export function getLatestSchema(): Partial { - return v210Schema as Partial + return v211Schema as Partial }