Skip to content

Commit

Permalink
[Wallet] Some minor cleanup (#4550)
Browse files Browse the repository at this point in the history
### Description

- Remove dead code related to Verifier app
- Move PGPNP flag to flags.ts
- Address some TODOs

### Backwards compatibility

Yes
  • Loading branch information
jmrossy authored Jul 29, 2020
1 parent 52d5de6 commit c4e0ede
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 118 deletions.
3 changes: 0 additions & 3 deletions packages/mobile/locales/en-US/walletFlow5.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"exchange": "Exchange",
"viewAll": "View All",
"thanksForVerifying": "Thanks for verifying",
"earnCeloRewards": "Earn Celo Rewards for verifying others",
"earnCeloGold": "Earn CELO by allowing the network to send verification texts from your phone",
"startEarning": "Start Earning",
"learnMore": "Learn More",
"goldIsWhereYouSave": "CELO is where you can save {{CeloDollars}} you have",
"manageCeloDollars": "Manage {{CeloDollars}}",
Expand Down
3 changes: 0 additions & 3 deletions packages/mobile/locales/es-419/walletFlow5.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"exchange": "Cambio",
"viewAll": "Ver Todo",
"thanksForVerifying": "Gracias por completar la verificación",
"earnCeloRewards": "Gana Recompensas Celo por verificar a otros",
"earnCeloGold": "Gane CELO al permitir que la red envíe mensajes de verificación desde tu teléfono",
"startEarning": "Comenzar a ganar",
"learnMore": "Saber más",
"goldIsWhereYouSave": "Convierta sus {{CeloDollars}} en CELO",
"manageCeloDollars": "Administrar {{CeloDollars}}",
Expand Down
35 changes: 12 additions & 23 deletions packages/mobile/src/account/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PincodeType } from 'src/account/reducer'
import { PaymentRequest } from 'src/account/types'

// TODO(Rossy): Remove the _ACTION suffix from these actions for consistency with other other names
export enum Actions {
SET_NAME = 'ACCOUNT/SET_NAME',
SET_PHONE_NUMBER = 'ACCOUNT/SET_PHONE_NUMBER',
Expand All @@ -10,14 +9,13 @@ export enum Actions {
SET_PINCODE = 'ACCOUNT/SET_PINCODE',
SET_PINCODE_SUCCESS = 'ACCOUNT/SET_PINCODE_SUCCESS',
SET_PINCODE_FAILURE = 'ACCOUNT/SET_PINCODE_FAILURE',
SET_ACCOUNT_CREATION_TIME_ACTION = 'ACCOUNT/SET_ACCOUNT_CREATION_TIME_ACTION',
SET_BACKUP_COMPLETED_ACTION = 'ACCOUNT/SET_BACKUP_COMPLETED_ACTION',
SET_BACKUP_DELAYED_ACTION = 'ACCOUNT/SET_BACKUP_DELAYED_ACTION',
SET_SOCIAL_BACKUP_COMPLETED_ACTION = 'ACCOUNT/SET_SOCIAL_BACKUP_COMPLETED_ACTION',
SET_ACCOUNT_CREATION_TIME = 'ACCOUNT/SET_ACCOUNT_CREATION_TIME',
SET_BACKUP_COMPLETED = 'ACCOUNT/SET_BACKUP_COMPLETED',
SET_BACKUP_DELAYED = 'ACCOUNT/SET_BACKUP_DELAYED',
SET_SOCIAL_BACKUP_COMPLETED = 'ACCOUNT/SET_SOCIAL_BACKUP_COMPLETED',
TOGGLE_BACKUP_STATE = 'ACCOUNT/TOGGLE_BACKUP_STATE',
UPDATE_INCOMING_PAYMENT_REQUESTS = 'ACCOUNT/UPDATE_INCOMING_PAYMENT_REQUESTS',
UPDATE_OUTGOING_PAYMENT_REQUESTS = 'ACCOUNT/UPDATE_OUTGOING_PAYMENT_REQUESTS',
DISMISS_EARN_REWARDS = 'ACCOUNT/DISMISS_EARN_REWARDS',
DISMISS_INVITE_FRIENDS = 'ACCOUNT/DISMISS_INVITE_FRIENDS',
DISMISS_GET_VERIFIED = 'ACCOUNT/DISMISS_GET_VERIFIED',
SET_USER_CONTACT_DETAILS = 'ACCOUNT/SET_USER_CONTACT_DETAILS',
Expand Down Expand Up @@ -65,19 +63,19 @@ export interface SetPincodeFailureAction {
}

export interface SetAccountCreationAction {
type: Actions.SET_ACCOUNT_CREATION_TIME_ACTION
type: Actions.SET_ACCOUNT_CREATION_TIME
}

export interface SetBackupCompletedAction {
type: Actions.SET_BACKUP_COMPLETED_ACTION
type: Actions.SET_BACKUP_COMPLETED
}

export interface SetBackupDelayedAction {
type: Actions.SET_BACKUP_DELAYED_ACTION
type: Actions.SET_BACKUP_DELAYED
}

export interface SetSocialBackupCompletedAction {
type: Actions.SET_SOCIAL_BACKUP_COMPLETED_ACTION
type: Actions.SET_SOCIAL_BACKUP_COMPLETED
}

export interface ToggleBackupState {
Expand All @@ -94,10 +92,6 @@ export interface UpdateOutgoingPaymentRequestsAction {
paymentRequests: PaymentRequest[]
}

export interface DismissEarnRewardsAction {
type: Actions.DISMISS_EARN_REWARDS
}

export interface DismissInviteFriendsAction {
type: Actions.DISMISS_INVITE_FRIENDS
}
Expand Down Expand Up @@ -139,7 +133,6 @@ export type ActionTypes =
| SetBackupDelayedAction
| SetSocialBackupCompletedAction
| ToggleBackupState
| DismissEarnRewardsAction
| DismissInviteFriendsAction
| DismissGetVerifiedAction
| UpdateIncomingPaymentRequestsAction
Expand Down Expand Up @@ -193,19 +186,19 @@ export const setPincodeFailure = (): SetPincodeFailureAction => ({
})

export const setAccountCreationTime = (): SetAccountCreationAction => ({
type: Actions.SET_ACCOUNT_CREATION_TIME_ACTION,
type: Actions.SET_ACCOUNT_CREATION_TIME,
})

export const setBackupCompleted = (): SetBackupCompletedAction => ({
type: Actions.SET_BACKUP_COMPLETED_ACTION,
type: Actions.SET_BACKUP_COMPLETED,
})

export const setBackupDelayed = (): SetBackupDelayedAction => ({
type: Actions.SET_BACKUP_DELAYED_ACTION,
type: Actions.SET_BACKUP_DELAYED,
})

export const setSocialBackupCompleted = (): SetSocialBackupCompletedAction => ({
type: Actions.SET_SOCIAL_BACKUP_COMPLETED_ACTION,
type: Actions.SET_SOCIAL_BACKUP_COMPLETED,
})

export const toggleBackupState = (): ToggleBackupState => ({
Expand All @@ -226,10 +219,6 @@ export const updateOutgoingPaymentRequests = (
paymentRequests,
})

export const dismissEarnRewards = (): DismissEarnRewardsAction => ({
type: Actions.DISMISS_EARN_REWARDS,
})

export const dismissInviteFriends = (): DismissInviteFriendsAction => ({
type: Actions.DISMISS_INVITE_FRIENDS,
})
Expand Down
15 changes: 4 additions & 11 deletions packages/mobile/src/account/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface State {
socialBackupCompleted: boolean
incomingPaymentRequests: PaymentRequest[]
outgoingPaymentRequests: PaymentRequest[]
dismissedEarnRewards: boolean
dismissedInviteFriends: boolean
dismissedGetVerified: boolean
promptFornoIfNeeded: boolean
Expand Down Expand Up @@ -61,7 +60,6 @@ export const initialState = {
backupCompleted: false,
backupDelayedTime: 0,
socialBackupCompleted: false,
dismissedEarnRewards: false,
dismissedInviteFriends: false,
dismissedGetVerified: false,
promptFornoIfNeeded: false,
Expand Down Expand Up @@ -126,22 +124,22 @@ export const reducer = (
pincodeType: PincodeType.Unset,
isSettingPin: false,
}
case Actions.SET_ACCOUNT_CREATION_TIME_ACTION:
case Actions.SET_ACCOUNT_CREATION_TIME:
return {
...state,
accountCreationTime: getRemoteTime(),
}
case Actions.SET_BACKUP_COMPLETED_ACTION:
case Actions.SET_BACKUP_COMPLETED:
return {
...state,
backupCompleted: true,
}
case Actions.SET_BACKUP_DELAYED_ACTION:
case Actions.SET_BACKUP_DELAYED:
return {
...state,
backupDelayedTime: getRemoteTime(),
}
case Actions.SET_SOCIAL_BACKUP_COMPLETED_ACTION:
case Actions.SET_SOCIAL_BACKUP_COMPLETED:
return {
...state,
socialBackupCompleted: true,
Expand All @@ -163,11 +161,6 @@ export const reducer = (
...state,
outgoingPaymentRequests: action.paymentRequests,
}
case Actions.DISMISS_EARN_REWARDS:
return {
...state,
dismissedEarnRewards: true,
}
case Actions.DISMISS_INVITE_FRIENDS:
return {
...state,
Expand Down
7 changes: 0 additions & 7 deletions packages/mobile/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@ export const DEFAULT_TESTNET = Config.DEFAULT_TESTNET || 'integration'
export const DAILY_PAYMENT_LIMIT_CUSD = 500
export const SMS_RETRIEVER_APP_SIGNATURE = Config.SMS_RETRIEVER_APP_SIGNATURE

// LINKS
export const CELO_VERIFIER_DOWNLOAD_LINK = 'https://celo.org/rewards'
export const CELO_VERIFIER_START_MINING_LINK = 'celo://verifier/start'

// TODO: remove special case for mainnet
export const DEFAULT_FORNO_URL = `https://${
DEFAULT_TESTNET === 'mainnet' ? 'rc1' : DEFAULT_TESTNET
}-forno.celo-testnet.org`

// FEATURE FLAGS
export const FIREBASE_ENABLED = stringToBoolean(Config.FIREBASE_ENABLED || 'true')
export const PROMOTE_REWARDS_APP = false
export const SHOW_TESTNET_BANNER = stringToBoolean(Config.SHOW_TESTNET_BANNER || 'false')
export const SHOW_GET_INVITE_LINK = stringToBoolean(Config.SHOW_GET_INVITE_LINK || 'false')
export const FORNO_ENABLED_INITIALLY = Config.FORNO_ENABLED_INITIALLY
Expand All @@ -73,8 +68,6 @@ export const FORNO_ENABLED_INITIALLY = Config.FORNO_ENABLED_INITIALLY
export const DEFAULT_SYNC_MODE: GethSyncMode = Config.DEFAULT_SYNC_MODE
? new BigNumber(Config.DEFAULT_SYNC_MODE).toNumber()
: GethSyncMode.Lightest
// TODO Remove when feature is stable
export const USE_PHONE_NUMBER_PRIVACY = true

// SECRETS
export const SEGMENT_API_KEY = keyOrUndefined(secretsFile, Config.SECRETS_KEY, 'SEGMENT_API_KEY')
Expand Down
1 change: 0 additions & 1 deletion packages/mobile/src/escrow/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ function* transferStableTokenToEscrow(action: EscrowTransferPaymentAction) {
NUM_ATTESTATIONS_REQUIRED
)
ValoraAnalytics.track(EscrowEvents.escrow_transfer_transfer_tx_sent)
// TODO check types
yield call(sendAndMonitorTransaction, action.txId, transferTx, account)
yield put(fetchSentEscrowPayments())
ValoraAnalytics.track(EscrowEvents.escrow_transfer_complete)
Expand Down
3 changes: 0 additions & 3 deletions packages/mobile/src/fees/CalculateFee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ interface ReclaimEscrowProps extends CommonProps {
paymentID: string
}

// TODO: remove this once we use TS 3.5
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

export type PropsWithoutChildren =
| Omit<InviteProps, 'children'>
| Omit<SendProps, 'children'>
Expand Down
2 changes: 2 additions & 0 deletions packages/mobile/src/flags.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Feature flags
export const features = {
SHOW_SHOW_REWARDS_APP_LINK: false,
USE_COMMENT_ENCRYPTION: true,
Expand All @@ -7,6 +8,7 @@ export const features = {
VERIFICATION_FORNO_RETRY: true,
CUSD_MOONPAY_ENABLED: false,
SHOW_CASH_OUT: false,
USE_PHONE_NUMBER_PRIVACY: true,
}

export const pausedFeatures = {
Expand Down
3 changes: 0 additions & 3 deletions packages/mobile/src/home/NotificationBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const storeDataNotificationsEnabled = {
goldToken: { educationCompleted: false },
account: {
backupCompleted: false,
dismissedEarnRewards: false,
dismissedInviteFriends: false,
dismissedGetVerified: false,
accountCreationTime: EXPIRED_BACKUP_TIME,
Expand All @@ -26,7 +25,6 @@ const storeDataNotificationsDisabled = {
goldToken: { educationCompleted: true },
account: {
backupCompleted: true,
dismissedEarnRewards: true,
dismissedInviteFriends: true,
dismissedGetVerified: true,
accountCreationTime: RECENT_BACKUP_TIME,
Expand Down Expand Up @@ -69,7 +67,6 @@ describe('NotificationBox', () => {
goldToken: { educationCompleted: false },
account: {
...storeDataNotificationsDisabled.account,
dismissedEarnRewards: false,
dismissedInviteFriends: false,
},
})
Expand Down
41 changes: 1 addition & 40 deletions packages/mobile/src/home/NotificationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import * as React from 'react'
import { WithTranslation } from 'react-i18next'
import { NativeScrollEvent, ScrollView, StyleSheet, View } from 'react-native'
import { connect } from 'react-redux'
import { dismissEarnRewards, dismissGetVerified, dismissInviteFriends } from 'src/account/actions'
import { dismissGetVerified, dismissInviteFriends } from 'src/account/actions'
import { getIncomingPaymentRequests, getOutgoingPaymentRequests } from 'src/account/selectors'
import { PaymentRequest } from 'src/account/types'
import { HomeEvents } from 'src/analytics/Events'
import { ScrollDirection } from 'src/analytics/types'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
import { PROMOTE_REWARDS_APP } from 'src/config'
import { EscrowedPayment } from 'src/escrow/actions'
import EscrowedPaymentReminderSummaryNotification from 'src/escrow/EscrowedPaymentReminderSummaryNotification'
import { getReclaimableEscrowPayments } from 'src/escrow/reducer'
Expand All @@ -26,15 +25,13 @@ import IncomingPaymentRequestSummaryNotification from 'src/paymentRequest/Incomi
import OutgoingPaymentRequestSummaryNotification from 'src/paymentRequest/OutgoingPaymentRequestSummaryNotification'
import { RootState } from 'src/redux/reducers'
import { isBackupTooLate } from 'src/redux/selectors'
import { navigateToVerifierApp } from 'src/utils/linking'

export enum NotificationBannerTypes {
incoming_tx_request = 'incoming_tx_request',
outgoing_tx_request = 'outgoing_tx_request',
escrow_tx_summary = 'escrow_tx_summary',
escrow_tx_pending = 'escrow_tx_pending',
celo_asset_education = 'celo_asset_education',
celo_rewards_education = 'celo_rewards_education',
invite_prompt = 'invite_prompt',
verification_prompt = 'verification_prompt',
backup_prompt = 'backup_prompt',
Expand All @@ -53,7 +50,6 @@ interface StateProps {
backupCompleted: boolean
numberVerified: boolean
goldEducationCompleted: boolean
dismissedEarnRewards: boolean
dismissedInviteFriends: boolean
dismissedGetVerified: boolean
incomingPaymentRequests: PaymentRequest[]
Expand All @@ -64,7 +60,6 @@ interface StateProps {
}

interface DispatchProps {
dismissEarnRewards: typeof dismissEarnRewards
dismissInviteFriends: typeof dismissInviteFriends
dismissGetVerified: typeof dismissGetVerified
}
Expand All @@ -77,7 +72,6 @@ const mapStateToProps = (state: RootState): StateProps => ({
goldEducationCompleted: state.goldToken.educationCompleted,
incomingPaymentRequests: getIncomingPaymentRequests(state),
outgoingPaymentRequests: getOutgoingPaymentRequests(state),
dismissedEarnRewards: state.account.dismissedEarnRewards,
dismissedInviteFriends: state.account.dismissedInviteFriends,
dismissedGetVerified: state.account.dismissedGetVerified,
backupTooLate: isBackupTooLate(state),
Expand All @@ -86,7 +80,6 @@ const mapStateToProps = (state: RootState): StateProps => ({
})

const mapDispatchToProps = {
dismissEarnRewards,
dismissInviteFriends,
dismissGetVerified,
}
Expand Down Expand Up @@ -140,7 +133,6 @@ export class NotificationBox extends React.Component<Props, State> {
backupCompleted,
numberVerified,
goldEducationCompleted,
dismissedEarnRewards,
dismissedInviteFriends,
dismissedGetVerified,
} = this.props
Expand Down Expand Up @@ -196,37 +188,6 @@ export class NotificationBox extends React.Component<Props, State> {
})
}

if (!dismissedEarnRewards && PROMOTE_REWARDS_APP) {
actions.push({
title: t('walletFlow5:earnCeloRewards'),
text: t('walletFlow5:earnCeloGold'),
icon: null,
callToActions: [
{
text: t('walletFlow5:startEarning'),
onPress: () => {
this.props.dismissEarnRewards()
ValoraAnalytics.track(HomeEvents.notification_select, {
notificationType: NotificationBannerTypes.celo_rewards_education,
selectedAction: NotificationBannerCTATypes.accept,
})
navigateToVerifierApp()
},
},
{
text: t('maybeLater'),
onPress: () => {
this.props.dismissEarnRewards()
ValoraAnalytics.track(HomeEvents.notification_select, {
notificationType: NotificationBannerTypes.celo_rewards_education,
selectedAction: NotificationBannerCTATypes.decline,
})
},
},
],
})
}

if (!goldEducationCompleted) {
actions.push({
title: t('global:celoGold'),
Expand Down
1 change: 0 additions & 1 deletion packages/mobile/src/home/WalletHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const storeData = {
goldToken: { educationCompleted: true },
account: {
backupCompleted: true,
dismissedEarnRewards: true,
dismissedInviteFriends: true,
accountCreationTime: new Date().getTime() - TWO_DAYS_MS,
paymentRequests: [],
Expand Down
2 changes: 0 additions & 2 deletions packages/mobile/src/home/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createSelector } from 'reselect'
import { getIncomingPaymentRequests, getOutgoingPaymentRequests } from 'src/account/selectors'
import { PROMOTE_REWARDS_APP } from 'src/config'
import { getReclaimableEscrowPayments } from 'src/escrow/reducer'
import { RootState } from 'src/redux/reducers'
import { isBackupTooLate } from 'src/redux/selectors'
Expand Down Expand Up @@ -28,7 +27,6 @@ export const callToActNotificationSelector = (state: RootState) => {
return (
!state.account.backupCompleted ||
!state.goldToken.educationCompleted ||
(!state.account.dismissedEarnRewards && PROMOTE_REWARDS_APP) ||
!state.account.dismissedInviteFriends ||
(!state.app.numberVerified && !state.account.dismissedGetVerified)
)
Expand Down
Loading

0 comments on commit c4e0ede

Please sign in to comment.