Skip to content

Commit

Permalink
[Wallet] Implement new import wallet flow designs (#1209)
Browse files Browse the repository at this point in the history
* Implement new import wallet flow designs including empty wallet warning
* Improve responsiveness of import wallet screen
* More robust error handling for import saga
* Add tests for import saga
* Cleanup redundant web3 zerosync mocks introduced in #1108
  • Loading branch information
jmrossy authored Oct 7, 2019
1 parent 31a8633 commit 25feb78
Show file tree
Hide file tree
Showing 81 changed files with 626 additions and 798 deletions.
8 changes: 8 additions & 0 deletions packages/mobile/__mocks__/src/geth/network-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DEFAULT_SYNC_MODE, DEFAULT_TESTNET } from 'src/web3/testnets'

export default {
[DEFAULT_TESTNET]: {
nodeDir: `.${DEFAULT_TESTNET}`,
syncMode: DEFAULT_SYNC_MODE,
},
}
4 changes: 4 additions & 0 deletions packages/mobile/__mocks__/src/web3/testnets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { GethSyncMode } from 'src/geth/consts'

export const DEFAULT_TESTNET = 'integration'
export const DEFAULT_SYNC_MODE: GethSyncMode = GethSyncMode.Ultralight
5 changes: 2 additions & 3 deletions packages/mobile/__mocks__/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ export default class {
},
getAccounts: () => {},
accounts: {
privateKeyToAccount: () =>
'0x1129eb2fbccdc663f4923a6495c35b096249812b589f7c4cd1dba01e1edaf724',
privateKeyToAccount: () => ({ address: '0x0000000000000000000000000000000000007E57' }),
wallet: {
add: () => null,
},
create: () => ({
address: '0x1129eb2fbccdc663f4923a6495c35b096249812b589f7c4cd1dba01e1edaf724',
address: '0x0000000000000000000000000000000000007E57',
privateKey: '0x1129eb2fbccdc663f4923a6495c35b096249812b589f7c4cd1dba01e1edaf724',
}),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/locales/en-US/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"canNotRequestFromUnverified": "Can not request from unverified users",
"restartApp": "Restart App",
"loading": "Loading…",
"invalidBackup": "Invalid Backup Key",
"invalidBackupPhrase": "Invalid Backup Key",
"importBackupFailed": "Importing Wallet Failed",
"inviteFailed": "Failure sending invite",
"importContactsFailed": "Failed to import contacts",
Expand Down
30 changes: 11 additions & 19 deletions packages/mobile/locales/en-US/nuxRestoreWallet3.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
{
"welcomeCelo": "Welcome to Celo",
"enterInvite":
"Enter your invitation code. If you do not have one, ask someone in the Celo Community to invite you. By joining this application, you agree to share your name & phone number with us. Learn more at celo.org",
"fullName": "Full Name",
"invitationCode": "Invitation Code",
"submit": "Submit",
"alreadyHaveWallet": "Already have a Celo Wallet? Restore it",
"restoreYourWallet": {
"title": "Restore your Celo Wallet",
"userYourBackupKey":
"Already have a Celo Wallet? Use your secure Backup Key to restore your wallet to this phone.",
"warning": "Warning ",
"restoreInPrivate": "Restore your Wallet in private "
},
"backupKeyPrompt": "Backup Key",
"title": "Restore your Celo Wallet",
"userYourBackupKey":
"Already have a Celo Wallet? Enter your Backup Key to restore it to this phone.",
"backupKeyPrompt":
"horse leopard dog monkey shark tiger lemur whale squid wolf squirrel mouse lion elephant cat shrimp bear penguin deer turtle fox zebra goat giraffe",
"tip": "Tip: ",
"backupKeyTip": "Backup Key words are separated by a space",
"continue": "Continue",
"cancel": "Cancel",
"restoreWallet": "Restore Celo Wallet"
"backupKeyTip": "Backup Keys are 24 words long, separated by a space.",
"restoreWallet": "Restore",
"emptyWalletWarning": "This wallet is empty.",
"useEmptyAnyway": "Would you like to use it anyway?",
"useEmptyWallet": "Use Empty Wallet",
"tryAnotherKey": "Try Another Backup Key"
}
2 changes: 1 addition & 1 deletion packages/mobile/locales/es-419/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"canNotRequestFromUnverified": "No se puede solicitar a usuarios no verificados.",
"restartApp": "Reiniciar la aplicación",
"loading": "Cargando…",
"invalidBackup": "Clave de respaldo inválida",
"invalidBackupPhrase": "Clave de respaldo inválida",
"importBackupFailed": "No se pudo importar el monedero",
"inviteFailed": "Falló el envío de la invitación",
"importContactsFailed": "Error al importar contactos",
Expand Down
30 changes: 11 additions & 19 deletions packages/mobile/locales/es-419/nuxRestoreWallet3.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
{
"welcomeCelo": "Te damos la bienvenida a Celo",
"enterInvite":
"Ingresegcódigo de invitación. Si no tiene uno, pídale a alguien de la comunidad de Celo que lo invite.\n\nAl unirse a esta aplicación, acuerda compartir tu nombre y número telefónico con nosotros. Obtenga más información en celo.org",
"fullName": "Nombre completo",
"invitationCode": "Código de invitación",
"submit": "Enviar",
"alreadyHaveWallet": "¿Ya tiene un Monedero Celo? Restáurelo",
"restoreWallet": "Restaurar el Monedero Celo",
"restoreYourWallet": {
"title": "Restaurar tu Monedero Celo",
"userYourBackupKey":
"¿Ya tiene un Monedero Celo? Use tu clave de respaldo segura para restaurar tu monedero a este teléfono.",
"warning": "¡Cuidado! ",
"restoreInPrivate": "Hágalo en privado"
},
"backupKeyPrompt": "Clave de respaldo",
"title": "Restaurar tu Monedero Celo",
"userYourBackupKey":
"¿Ya tiene un Monedero Celo? Ingrese su Clave de Respaldo para restaurarla a este teléfono.",
"backupKeyPrompt":
"caballo leopardo perro mono tiburón tigre lémur ballena calamar lobo ardilla ratón león elefante gato camarones oso pingüino...",
"tip": "Consejo: ",
"backupKeyTip": "las palabras de la clave de respaldo están separadas por un espacio",
"continue": "Continuar",
"cancel": "Cancelar"
"backupKeyTip": "Las Claves de Respaldo son de 24 palabras, separadas por un espacio.",
"restoreWallet": "Restaurar",
"emptyWalletWarning": "Este Monedero esta vacio",
"useEmptyAnyway": "¿Te gustaría usarlo de todos modos?",
"useEmptyWallet": "Usar Monedero Vacío",
"tryAnotherKey": "Probar con otra Clave de Respaldo"
}
2 changes: 1 addition & 1 deletion packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"@celo/client": "640a41f",
"@celo/react-native-sms-retriever": "git+https://github.com/celo-org/react-native-sms-retriever#d3a2fdb",
"@celo/utils": "^0.1.0",
"@celo/utils": "^0.1.1",
"@celo/walletkit": "^0.0.14",
"@react-native-community/netinfo": "^2.0.4",
"@segment/analytics-react-native": "^1.1.0-beta.1",
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/Account.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { createMockStore } from 'test/utils'

jest.useFakeTimers()

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('Account', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/DollarEducation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import * as renderer from 'react-test-renderer'
import DollarEducation from 'src/account/DollarEducation'
import { createMockStore } from 'test/utils'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('DollarEducation', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/EditProfile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import { setName } from 'src/account/actions'
import { EditProfile } from 'src/account/EditProfile'
import { createMockStore, getMockI18nProps } from 'test/utils'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

it('renders the EditProfile Component', () => {
const store = createMockStore()
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/Education.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ const educationProps = {
onFinish: jest.fn(),
}

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('Education', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/GoldEducation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import * as renderer from 'react-test-renderer'
import GoldEducation from 'src/account/GoldEducation'
import { createMockStore } from 'test/utils'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('GoldEducation', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/Invite.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import Invite from 'src/account/Invite'
import { createMockStore } from 'test/utils'
import { mockE164NumberToInvitableRecipient, mockNavigation } from 'test/values'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('Invite', () => {
it('renders correctly with recipients', () => {
const tree = renderer.create(
Expand Down
9 changes: 0 additions & 9 deletions packages/mobile/src/account/InviteReview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ jest.mock('src/identity/verification', () => {
return { isPhoneVerified: jest.fn(() => true) }
})

jest.mock('src/web3/contracts', () => ({
web3: {
utils: {
fromWei: jest.fn((x: any) => x / 1e18),
},
},
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('InviteReview', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/PhotosEducation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import * as renderer from 'react-test-renderer'
import PhotosEducation from 'src/account/PhotosEducation'
import { createMockStore } from 'test/utils'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('PhotosEducation', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/account/Profile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import { Screens } from 'src/navigator/Screens'
import { createMockStore } from 'test/utils'
import { mockNavigation } from 'test/values'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

function profileFactory() {
return (
<Provider store={createMockStore({})}>
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/app/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ jest.mock('src/redux/sagas', () => {
}
})

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('App', () => {
it('renders an ApolloProvider', () => {
const wrapper = shallow(<App />)
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/app/Debug.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import * as renderer from 'react-test-renderer'
import Debug from 'src/app/Debug'
import { createMockStore } from 'test/utils'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('Debug', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
3 changes: 2 additions & 1 deletion packages/mobile/src/app/ErrorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export enum ErrorMessages {
NSF_DOLLARS = 'notEnoughDollarsError',
NSF_TO_SEND = 'needMoreFundsToSend',
INVALID_AMOUNT = 'invalidAmount',
INVALID_BACKUP = 'invalidBackup',
INVALID_BACKUP_PHRASE = 'invalidBackupPhrase',
EMPTY_BACKUP_PHRASE = 'emptyBackupPhrase',
IMPORT_BACKUP_FAILED = 'importBackupFailed',
INVALID_PHONE_NUMBER = 'nuxVerification2:invalidPhone',
NOT_READY_FOR_CODE = 'nuxVerification2:notReadyForCode',
Expand Down
9 changes: 0 additions & 9 deletions packages/mobile/src/app/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ jest.mock('src/firebase/firebase', () => ({
getVersionInfo: jest.fn(async () => ({ deprecated: false })),
}))

jest.mock('src/web3/contracts', () => ({
web3: {
utils: {
fromWei: jest.fn((x: any) => x / 1e18),
},
},
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

const { navigate } = require('src/navigator/NavigationService')
const { getVersionInfo } = require('src/firebase/firebase')

Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/components/AccountOverview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { getMockI18nProps } from 'test/utils'
const SAMPLE_BALANCE = '55.00001'
const exchangeRatePair: ExchangeRatePair = { goldMaker: '0.11', dollarMaker: '10' }

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

it('renders correctly when ready', () => {
const tree = renderer.create(
<AccountOverview
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/escrow/EscrowedPaymentLineItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import * as renderer from 'react-test-renderer'
import PaymentRequestNotificationInner from 'src/paymentRequest/PaymentRequestNotificationInner'
import { mockRecipientWithPhoneNumber } from 'test/values'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

it('renders correctly', () => {
const tree = renderer.create(
<PaymentRequestNotificationInner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { mockE164Number, mockRecipient } from 'test/values'

const store = createMockStore()

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('ReclaimPaymentConfirmationCard', () => {
it('renders correctly for send payment confirmation', () => {
const tree = renderer.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ const TEST_FEE = new BigNumber(10000000000000000)

jest.mock('src/escrow/saga')

jest.mock('src/web3/contracts', () => ({
web3: {
utils: {
fromWei: jest.fn((x: any) => x / 1e18),
},
},
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

const mockedGetReclaimEscrowFee = getReclaimEscrowFee as jest.Mock

const store = createMockStore()
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/exchange/ExchangeTradeScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ jest.mock('src/shared/DisconnectBanner', () => ({
DisconnectBanner: () => null,
}))

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

const store = createMockStore({
exchange: {
exchangeRatePair,
Expand Down
10 changes: 0 additions & 10 deletions packages/mobile/src/fees/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ jest.mock('@celo/walletkit', () => ({
},
}))

jest.mock('src/web3/contracts', () => ({
web3: {
utils: {
fromWei: jest.fn((x: any) => x / 1e18),
toWei: jest.fn((x: any) => x * 1e18),
},
},
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe(estimateFeeSaga, () => {
beforeAll(() => {
jest.useRealTimers()
Expand Down
4 changes: 0 additions & 4 deletions packages/mobile/src/home/CeloDollarsOverview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import * as renderer from 'react-test-renderer'
import CeloDollarsOverview from 'src/home/CeloDollarsOverview'
import { createMockStore } from 'test/utils'

jest.mock('src/web3/contracts', () => ({
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('CeloDollarsOverview', () => {
it('renders correctly', () => {
const tree = renderer.create(
Expand Down
9 changes: 0 additions & 9 deletions packages/mobile/src/home/NotificationBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ const storeData = {
},
}

jest.mock('src/web3/contracts', () => ({
web3: {
utils: {
fromWei: jest.fn((x: any) => x / 1e18),
},
},
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('NotificationBox', () => {
it('Simple test', () => {
// const store = createMockStore(storeData)
Expand Down
9 changes: 0 additions & 9 deletions packages/mobile/src/home/WalletHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ const storeData = {
jest.mock('src/components/AccountOverview')
jest.mock('src/home/TransactionsList')

jest.mock('src/web3/contracts', () => ({
web3: {
utils: {
fromWei: jest.fn((x: any) => x / 1e18),
},
},
isZeroSyncMode: jest.fn().mockReturnValueOnce(false),
}))

describe('Testnet banner', () => {
it('Shows testnet banner for 5 seconds', async () => {
const store = createMockStore({
Expand Down
Loading

0 comments on commit 25feb78

Please sign in to comment.