diff --git a/packages/mobile/locales/en-US/accountScreen10.json b/packages/mobile/locales/en-US/accountScreen10.json index 925756cb466..6faaba98784 100644 --- a/packages/mobile/locales/en-US/accountScreen10.json +++ b/packages/mobile/locales/en-US/accountScreen10.json @@ -10,6 +10,10 @@ "shareAnalytics": "Share Analytics", "shareAnalytics_detail": "We collect anonymized data about how you use Celo to help improve the application for everyone.", + "celoLite": "Celo Lite", + "enableCeloLite": "Enable Celo Lite", + "celoLiteDetail": + "Celo Lite mode allows you to communicate with the Celo Network through a trusted node. You can always change this mode in app settings.", "testFaqHere": "<0>Test FAQ is <1>here", "termsOfServiceHere": "<0>Terms of service are <1>here", "editProfile": "Edit Profile", diff --git a/packages/mobile/locales/es-419/accountScreen10.json b/packages/mobile/locales/es-419/accountScreen10.json index 6bc3d025916..acd51bba54f 100755 --- a/packages/mobile/locales/es-419/accountScreen10.json +++ b/packages/mobile/locales/es-419/accountScreen10.json @@ -10,6 +10,10 @@ "shareAnalytics": "Compartir estadisticas de uso", "shareAnalytics_detail": "Recopilamos datos anónimos sobre cómo utiliza Celo para ayudar a mejorar la aplicación para todos.", + "celoLite": "Celo Lite", + "enableCeloLite": "Habilitar Celo Lite", + "celoLiteDetail": + "El modo Celo Lite te permite comunicarte con la Red Celo a través de un nodo confiable. Puedes cambiar este modo en la configuración de la aplicación.", "testFaqHere": "<1>Aquí<0> están las preguntas frecuentes de la prueba. ", "termsOfServiceHere": "<1>Aquí<0> están las Condiciones de servicio.", "editProfile": "Editar perfil", diff --git a/packages/mobile/src/account/Account.tsx b/packages/mobile/src/account/Account.tsx index bd017c8beea..6865c11aff9 100644 --- a/packages/mobile/src/account/Account.tsx +++ b/packages/mobile/src/account/Account.tsx @@ -109,6 +109,10 @@ export class Account extends React.Component { navigate(Screens.Analytics, { nextScreen: Screens.Account }) } + goToCeloLite() { + navigate(Screens.CeloLite, { nextScreen: Screens.Account }) + } + goToFAQ() { navigateToURI(FAQ_LINK) } @@ -229,6 +233,9 @@ export class Account extends React.Component { )} + {/* // TODO(anna) Disabled until switch geth on/off is implemented + + */} { + it('renders correctly', () => { + const tree = renderer.create( + + + + ) + expect(tree).toMatchSnapshot() + }) +}) diff --git a/packages/mobile/src/account/Analytics.tsx b/packages/mobile/src/account/Analytics.tsx index 6eb0fc2ad04..33cfabcfa39 100644 --- a/packages/mobile/src/account/Analytics.tsx +++ b/packages/mobile/src/account/Analytics.tsx @@ -1,7 +1,6 @@ import SettingsSwitchItem from '@celo/react-components/components/SettingsSwitchItem' import colors from '@celo/react-components/styles/colors' import fontStyles from '@celo/react-components/styles/fonts' -import variables from '@celo/react-components/styles/variables' import * as React from 'react' import { WithNamespaces, withNamespaces } from 'react-i18next' import { ScrollView, StyleSheet, Text } from 'react-native' @@ -50,27 +49,10 @@ export class Analytics extends React.Component { } const style = StyleSheet.create({ - accountHeader: { - paddingTop: 20, - }, - input: { - borderWidth: 1, - borderRadius: 3, - borderColor: '#EEEEEE', - padding: 5, - height: 54, - margin: 20, - width: variables.width - 40, - fontSize: 16, - }, scrollView: { flex: 1, backgroundColor: colors.background, }, - container: { - flex: 1, - paddingLeft: 20, - }, }) export default connect( diff --git a/packages/mobile/src/account/CeloLite.test.tsx b/packages/mobile/src/account/CeloLite.test.tsx new file mode 100644 index 00000000000..84804279238 --- /dev/null +++ b/packages/mobile/src/account/CeloLite.test.tsx @@ -0,0 +1,17 @@ +import * as React from 'react' +import 'react-native' +import { Provider } from 'react-redux' +import * as renderer from 'react-test-renderer' +import CeloLite from 'src/account/CeloLite' +import { createMockStore } from 'test/utils' + +describe('CeloLite', () => { + it('renders correctly', () => { + const tree = renderer.create( + + + + ) + expect(tree).toMatchSnapshot() + }) +}) diff --git a/packages/mobile/src/account/CeloLite.tsx b/packages/mobile/src/account/CeloLite.tsx new file mode 100644 index 00000000000..2711ae78abb --- /dev/null +++ b/packages/mobile/src/account/CeloLite.tsx @@ -0,0 +1,65 @@ +import SettingsSwitchItem from '@celo/react-components/components/SettingsSwitchItem' +import colors from '@celo/react-components/styles/colors' +import fontStyles from '@celo/react-components/styles/fonts' +import * as React from 'react' +import { WithNamespaces, withNamespaces } from 'react-i18next' +import { ScrollView, StyleSheet, Text } from 'react-native' +import { connect } from 'react-redux' +import i18n, { Namespaces } from 'src/i18n' +import { headerWithCancelButton } from 'src/navigator/Headers' +import { RootState } from 'src/redux/reducers' +import { setZeroSyncMode } from 'src/web3/actions' + +interface StateProps { + zeroSyncEnabled: boolean +} + +interface DispatchProps { + setZeroSyncMode: typeof setZeroSyncMode +} + +type Props = StateProps & DispatchProps & WithNamespaces + +const mapDispatchToProps = { + setZeroSyncMode, +} + +const mapStateToProps = (state: RootState): StateProps => { + return { + zeroSyncEnabled: state.web3.zeroSyncMode, + } +} + +export class CeloLite extends React.Component { + static navigationOptions = () => ({ + ...headerWithCancelButton, + headerTitle: i18n.t('accountScreen10:celoLite'), + }) + + render() { + const { zeroSyncEnabled, t } = this.props + return ( + + + {t('enableCeloLite')} + + + ) + } +} + +const style = StyleSheet.create({ + scrollView: { + flex: 1, + backgroundColor: colors.background, + }, +}) + +export default connect( + mapStateToProps, + mapDispatchToProps +)(withNamespaces(Namespaces.accountScreen10)(CeloLite)) diff --git a/packages/mobile/src/account/EditProfile.tsx b/packages/mobile/src/account/EditProfile.tsx index 0b0fe4c3cb9..76b394338c3 100644 --- a/packages/mobile/src/account/EditProfile.tsx +++ b/packages/mobile/src/account/EditProfile.tsx @@ -73,9 +73,6 @@ export class EditProfile extends React.Component { } const style = StyleSheet.create({ - accountHeader: { - paddingTop: 20, - }, input: { borderWidth: 1, borderRadius: 3, @@ -90,10 +87,6 @@ const style = StyleSheet.create({ flex: 1, backgroundColor: colors.background, }, - container: { - flex: 1, - paddingLeft: 20, - }, }) export default connect( diff --git a/packages/mobile/src/account/Education.tsx b/packages/mobile/src/account/Education.tsx index 66a86b0385f..471d673e468 100644 --- a/packages/mobile/src/account/Education.tsx +++ b/packages/mobile/src/account/Education.tsx @@ -189,20 +189,6 @@ const style = StyleSheet.create({ flex: 1, paddingHorizontal: 20, }, - footerLink: { - color: colors.celoGreen, - textAlign: 'center', - marginTop: 10, - marginBottom: 25, - }, - circleContainer: { - flex: 0, - width: PROGRESS_CIRCLE_PASSIVE_SIZE, - height: PROGRESS_CIRCLE_PASSIVE_SIZE, - alignItems: 'center', - justifyContent: 'center', - margin: 5, - }, circle: { flex: 0, backgroundColor: colors.inactive, diff --git a/packages/mobile/src/account/Invite.tsx b/packages/mobile/src/account/Invite.tsx index 57739ab2989..0b8dd33ebd0 100644 --- a/packages/mobile/src/account/Invite.tsx +++ b/packages/mobile/src/account/Invite.tsx @@ -135,15 +135,6 @@ const style = StyleSheet.create({ flex: 1, backgroundColor: colors.background, }, - inviteHeadline: { - fontSize: 24, - lineHeight: 39, - color: colors.dark, - }, - label: { - alignSelf: 'center', - textAlign: 'center', - }, }) export default componentWithAnalytics( diff --git a/packages/mobile/src/account/Licenses.test.tsx b/packages/mobile/src/account/Licenses.test.tsx new file mode 100644 index 00000000000..fc603cf69e7 --- /dev/null +++ b/packages/mobile/src/account/Licenses.test.tsx @@ -0,0 +1,17 @@ +import * as React from 'react' +import 'react-native' +import { Provider } from 'react-redux' +import * as renderer from 'react-test-renderer' +import Licenses from 'src/account/Licenses' +import { createMockStore } from 'test/utils' + +describe('Licenses', () => { + it('renders correctly', () => { + const tree = renderer.create( + + + + ) + expect(tree).toMatchSnapshot() + }) +}) diff --git a/packages/mobile/src/account/Profile.tsx b/packages/mobile/src/account/Profile.tsx index fe0e4936533..ee712ead8b5 100644 --- a/packages/mobile/src/account/Profile.tsx +++ b/packages/mobile/src/account/Profile.tsx @@ -65,9 +65,6 @@ export class Profile extends React.Component { } const style = StyleSheet.create({ - accountHeader: { - paddingTop: 20, - }, accountProfile: { paddingLeft: 10, paddingTop: 30, @@ -76,26 +73,6 @@ const style = StyleSheet.create({ flexDirection: 'column', alignItems: 'center', }, - accountFooter: { - flex: 1, - flexDirection: 'row', - justifyContent: 'center', - alignItems: 'center', - height: 50, - margin: 10, - }, - accountFooterText: { - paddingBottom: 10, - }, - editProfileButton: { - height: 28, - width: 110, - }, - image: { - height: 55, - width: 55, - borderRadius: 50, - }, underlinedBox: { borderTopWidth: 1, borderColor: '#EEEEEE', diff --git a/packages/mobile/src/account/__snapshots__/Analytics.test.tsx.snap b/packages/mobile/src/account/__snapshots__/Analytics.test.tsx.snap new file mode 100644 index 00000000000..74b75f43f3e --- /dev/null +++ b/packages/mobile/src/account/__snapshots__/Analytics.test.tsx.snap @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Analytics renders correctly 1`] = ` + + + + + + + shareAnalytics + + + + + + + + + shareAnalytics_detail + + + + + +`; diff --git a/packages/mobile/src/account/__snapshots__/CeloLite.test.tsx.snap b/packages/mobile/src/account/__snapshots__/CeloLite.test.tsx.snap new file mode 100644 index 00000000000..0a3080730d9 --- /dev/null +++ b/packages/mobile/src/account/__snapshots__/CeloLite.test.tsx.snap @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CeloLite renders correctly 1`] = ` + + + + + + + enableCeloLite + + + + + + + + + celoLiteDetail + + + + + +`; diff --git a/packages/mobile/src/account/__snapshots__/Licenses.test.tsx.snap b/packages/mobile/src/account/__snapshots__/Licenses.test.tsx.snap new file mode 100644 index 00000000000..3c6640ba55c --- /dev/null +++ b/packages/mobile/src/account/__snapshots__/Licenses.test.tsx.snap @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Licenses renders correctly 1`] = ` + + + +`; diff --git a/packages/mobile/src/navigator/Navigator.tsx b/packages/mobile/src/navigator/Navigator.tsx index df1f10a5988..ed22c7231ff 100644 --- a/packages/mobile/src/navigator/Navigator.tsx +++ b/packages/mobile/src/navigator/Navigator.tsx @@ -2,6 +2,7 @@ import { Platform } from 'react-native' import { createStackNavigator, createSwitchNavigator, StackNavigatorConfig } from 'react-navigation' import Account from 'src/account/Account' import Analytics from 'src/account/Analytics' +import CeloLite from 'src/account/CeloLite' import DollarEducation from 'src/account/DollarEducation' import EditProfile from 'src/account/EditProfile' import GoldEducation from 'src/account/GoldEducation' @@ -152,6 +153,7 @@ const AppStack = createStackNavigator( [Stacks.RequestStack]: { screen: RequestStack }, [Screens.Language]: { screen: Language }, [Screens.Analytics]: { screen: Analytics }, + [Screens.CeloLite]: { screen: CeloLite }, [Screens.SetClock]: { screen: SetClock }, [Screens.EditProfile]: { screen: EditProfile }, [Screens.Profile]: { screen: Profile }, diff --git a/packages/mobile/src/navigator/Screens.tsx b/packages/mobile/src/navigator/Screens.tsx index 7c2fc7347d1..4f19dbeb6b8 100644 --- a/packages/mobile/src/navigator/Screens.tsx +++ b/packages/mobile/src/navigator/Screens.tsx @@ -11,6 +11,7 @@ export enum Screens { Account = 'Account', Analytics = 'Analytics', Backup = 'Backup', + CeloLite = 'CeloLite', DappKitAccountAuth = 'DappKitAccountAuth', DappKitSignTxScreen = 'DappKitSignTxScreen', DappKitTxDataScreen = 'DappKitTxDataScreen', diff --git a/packages/mobile/src/redux/sagas.ts b/packages/mobile/src/redux/sagas.ts index 798967ac62f..fe3250573ac 100644 --- a/packages/mobile/src/redux/sagas.ts +++ b/packages/mobile/src/redux/sagas.ts @@ -19,6 +19,7 @@ import { networkInfoSaga } from 'src/networkInfo/saga' import { sendSaga } from 'src/send/saga' import { stableTokenSaga } from 'src/stableToken/saga' import Logger from 'src/utils/Logger' +import { web3Saga } from 'src/web3/saga' const loggerBlacklist = [ 'persist/REHYDRATE', @@ -75,4 +76,5 @@ export function* rootSaga() { yield spawn(dappKitSaga) yield spawn(feesSaga) yield spawn(localCurrencySaga) + yield spawn(web3Saga) } diff --git a/packages/mobile/src/web3/actions.ts b/packages/mobile/src/web3/actions.ts index fad10e98b10..3726b9a3088 100644 --- a/packages/mobile/src/web3/actions.ts +++ b/packages/mobile/src/web3/actions.ts @@ -10,6 +10,7 @@ export enum Actions { SET_COMMENT_KEY = 'WEB3/SET_COMMENT_KEY', SET_PROGRESS = 'WEB3/SET_PROGRESS', SET_IS_READY = 'WEB3/SET_IS_READY', + SET_IS_ZERO_SYNC = 'WEB3/SET_IS_ZERO_SYNC', SET_BLOCK_NUMBER = 'WEB3/SET_BLOCK_NUMBER', REQUEST_SYNC_PROGRESS = 'WEB3/REQUEST_SYNC_PROGRESS', UPDATE_WEB3_SYNC_PROGRESS = 'WEB3/UPDATE_WEB3_SYNC_PROGRESS', @@ -20,6 +21,11 @@ export interface SetAccountAction { address: string } +export interface SetIsZeroSyncAction { + type: Actions.SET_IS_ZERO_SYNC + zeroSyncMode: boolean +} + export interface SetCommentKeyAction { type: Actions.SET_COMMENT_KEY commentKey: string @@ -41,6 +47,7 @@ export interface UpdateWeb3SyncProgressAction { export type ActionTypes = | SetAccountAction + | SetIsZeroSyncAction | SetCommentKeyAction | SetLatestBlockNumberAction | UpdateWeb3SyncProgressAction @@ -53,6 +60,13 @@ export const setAccount = (address: string): SetAccountAction => { } } +export const setZeroSyncMode = (zeroSyncMode: boolean): SetIsZeroSyncAction => { + return { + type: Actions.SET_IS_ZERO_SYNC, + zeroSyncMode, + } +} + export const setPrivateCommentKey = (commentKey: string): SetCommentKeyAction => { return { type: Actions.SET_COMMENT_KEY, diff --git a/packages/mobile/src/web3/reducer.ts b/packages/mobile/src/web3/reducer.ts index 7c10b037aba..68184ca2667 100644 --- a/packages/mobile/src/web3/reducer.ts +++ b/packages/mobile/src/web3/reducer.ts @@ -1,3 +1,5 @@ +import { GethSyncMode } from 'src/geth/consts' +import networkConfig from 'src/geth/networkConfig' import { getRehydratePayload, REHYDRATE, RehydrateAction } from 'src/redux/persist-helper' import { Actions, ActionTypes } from 'src/web3/actions' @@ -10,6 +12,7 @@ export interface State { latestBlockNumber: number account: string | null commentKey: string | null + zeroSyncMode: boolean } const initialState: State = { @@ -21,6 +24,7 @@ const initialState: State = { latestBlockNumber: 0, account: null, commentKey: null, + zeroSyncMode: networkConfig.syncMode === GethSyncMode.ZeroSync, } export const reducer = ( @@ -46,6 +50,11 @@ export const reducer = ( ...state, account: action.address, } + case Actions.SET_IS_ZERO_SYNC: + return { + ...state, + zeroSyncMode: action.zeroSyncMode, + } case Actions.SET_COMMENT_KEY: return { ...state, diff --git a/packages/mobile/src/web3/saga.ts b/packages/mobile/src/web3/saga.ts index cde696e55de..fc5550dbef4 100644 --- a/packages/mobile/src/web3/saga.ts +++ b/packages/mobile/src/web3/saga.ts @@ -4,7 +4,7 @@ import * as Crypto from 'crypto' import { generateMnemonic, mnemonicToSeedHex } from 'react-native-bip39' import * as RNFS from 'react-native-fs' import { REHYDRATE } from 'redux-persist/es/constants' -import { call, delay, put, race, select, take } from 'redux-saga/effects' +import { call, delay, put, race, select, spawn, take, takeLatest } from 'redux-saga/effects' import { setAccountCreationTime } from 'src/account/actions' import { getPincode } from 'src/account/saga' import CeloAnalytics from 'src/analytics/CeloAnalytics' @@ -22,6 +22,7 @@ import { Actions, getLatestBlock, setAccount, + SetIsZeroSyncAction, setLatestBlockNumber, setPrivateCommentKey, updateWeb3SyncProgress, @@ -344,3 +345,17 @@ export function* getConnectedUnlockedAccount() { throw new Error(ErrorMessages.INCORRECT_PIN) } } + +export function* switchZeroSyncMode(action: SetIsZeroSyncAction) { + Logger.info(TAG + '@switchZeroSyncMode', `Zero sync mode will change to: ${action.zeroSyncMode}`) + // TODO(anna) implement switching geth on/off, changing web3 provider + return true +} + +export function* watchZeroSyncMode() { + yield takeLatest(Actions.SET_IS_ZERO_SYNC, switchZeroSyncMode) +} + +export function* web3Saga() { + yield spawn(watchZeroSyncMode) +} diff --git a/packages/mobile/src/web3/selectors.ts b/packages/mobile/src/web3/selectors.ts index bb30016381d..90495276a22 100644 --- a/packages/mobile/src/web3/selectors.ts +++ b/packages/mobile/src/web3/selectors.ts @@ -1,5 +1,6 @@ import { RootState } from 'src/redux/reducers' export const currentAccountSelector = (state: RootState) => state.web3.account +export const zeroSyncSelector = (state: RootState) => state.web3.zeroSyncMode export const privateCommentKeySelector = (state: RootState) => state.web3.commentKey diff --git a/packages/mobile/test/schemas.ts b/packages/mobile/test/schemas.ts index f4f259f0fa7..1ced74f71bc 100644 --- a/packages/mobile/test/schemas.ts +++ b/packages/mobile/test/schemas.ts @@ -56,6 +56,7 @@ export const vNeg1Schema = { account: '0x0000000000000000000000000000000000007E57', commentKey: '0x0000000000000000000000000000000000008F68', gasPriceLastUpdated: 0, + zeroSyncMode: false, }, identity: { attestationCodes: [],