From 5e21ef521b04607d5736c566fcb55a95d2e3e34b Mon Sep 17 00:00:00 2001 From: stackchain <30806844+stackchain@users.noreply.github.com> Date: Tue, 3 May 2022 16:26:53 -0400 Subject: [PATCH] [chore] CR update --- src/TxHistory/TxHistoryNavigator.tsx | 2 +- src/appStorage.test.ts | 19 ++++- src/appStorage.ts | 10 +-- .../ErrorBoundary/ErrorBoundary.tsx | 85 ++++++++++++++++--- 4 files changed, 93 insertions(+), 23 deletions(-) diff --git a/src/TxHistory/TxHistoryNavigator.tsx b/src/TxHistory/TxHistoryNavigator.tsx index 2a9774d213..21548c9622 100644 --- a/src/TxHistory/TxHistoryNavigator.tsx +++ b/src/TxHistory/TxHistoryNavigator.tsx @@ -71,7 +71,7 @@ export const TxHistoryNavigator = () => { name="history-details" component={TxDetails} options={({route}) => ({ - title: formatDateToSeconds(transactionInfos[route.params.id].submittedAt), + title: formatDateToSeconds(transactionInfos[route.params.id]?.submittedAt), })} /> diff --git a/src/appStorage.test.ts b/src/appStorage.test.ts index 06f197e4ca..5088432acd 100644 --- a/src/appStorage.test.ts +++ b/src/appStorage.test.ts @@ -52,7 +52,13 @@ describe('migrateWalletMetas()', () => { await storage.write(`/wallet/${meta.id}`, meta) await storage.write(`/wallet/${meta.id}/data`, mockedWalletData) const walletMetas = [meta] - const expected = [{...mockedWalletMeta, networkId: NETWORK_REGISTRY.JORMUNGANDR}] + const expected = [ + { + ...mockedWalletMeta, + networkId: NETWORK_REGISTRY.JORMUNGANDR, + walletImplementationId: WALLETS.JORMUNGANDR_ITN.WALLET_IMPLEMENTATION_ID, + }, + ] const result = await migrateWalletMetas(walletMetas) @@ -64,7 +70,14 @@ describe('migrateWalletMetas()', () => { await storage.write(`/wallet/${meta.id}`, meta) await storage.write(`/wallet/${meta.id}/data`, mockedWalletData) const walletMetas = [meta] - const expected = [{...mockedWalletMeta, isShelley: false, networkId: NETWORK_REGISTRY.HASKELL_SHELLEY}] + const expected = [ + { + ...mockedWalletMeta, + isShelley: false, + networkId: NETWORK_REGISTRY.HASKELL_SHELLEY, + walletImplementationId: WALLETS.HASKELL_BYRON.WALLET_IMPLEMENTATION_ID, + }, + ] const result = await migrateWalletMetas(walletMetas) @@ -198,7 +211,7 @@ describe('migrateWalletMetas()', () => { }) it('should set checksum with empty data when there is no addressGenerator in the wallet/data ', async () => { const meta = {...mockedWalletMeta} - const data = {...mockedWalletData, externalChain: null} + const data = {...mockedWalletData, externalChain: {}} delete meta.checksum await storage.write(`/wallet/${meta.id}`, meta) await storage.write(`/wallet/${meta.id}/data`, data) diff --git a/src/appStorage.ts b/src/appStorage.ts index 0f2ede351c..b25626eb20 100644 --- a/src/appStorage.ts +++ b/src/appStorage.ts @@ -41,7 +41,7 @@ async function toShelleyWalletMeta(currentWalletMeta: Partial): Prom // migrate checksum if (!currentWalletMeta?.checksum) { - if (walletData != null && walletData.externalChain?.addressGenerator != null) { + if (walletData != null && walletData?.externalChain?.addressGenerator != null) { const {accountPubKeyHex} = walletData.externalChain.addressGenerator switch (walletImplementationId) { case WALLETS.HASKELL_BYRON.WALLET_IMPLEMENTATION_ID: @@ -59,8 +59,8 @@ async function toShelleyWalletMeta(currentWalletMeta: Partial): Prom await migrateAttribute('checksum', walletMetaUpdate) } - // missing implementation id - if (!currentWalletMeta?.walletImplementationId && walletImplementationId) { + // resolving to a different implementation id + if (currentWalletMeta?.walletImplementationId !== walletImplementationId) { walletMetaUpdate.walletImplementationId = walletImplementationId await migrateAttribute('walletImplementationId', walletMetaUpdate) } @@ -100,7 +100,7 @@ function migrateAttribute(attr: keyof WalletMeta, walletMetaUpdated: Partial -1 && + && Object.values(WALLET_IMPLEMENTATION_REGISTRY).includes(walletMeta?.walletImplementationId) && ('isShelley' in walletMeta && typeof walletMeta.isShelley === 'boolean' || !('isShelley' in walletMeta)) diff --git a/src/components/ErrorBoundary/ErrorBoundary.tsx b/src/components/ErrorBoundary/ErrorBoundary.tsx index bbf6dd18f6..07f4a927d5 100644 --- a/src/components/ErrorBoundary/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary/ErrorBoundary.tsx @@ -1,8 +1,12 @@ import React, {Component, ErrorInfo, ReactNode} from 'react' -import {Text, View} from 'react-native' +import {BackHandler, Image, Platform, ScrollView, StyleSheet, Text, View} from 'react-native' +import {Divider} from 'react-native-paper' +import image from '../../../legacy/assets/img/error.png' +import {Button, CopyButton} from '../../../legacy/components/UiKit' import {Logger} from '../../../legacy/utils/logging' - +import {ExpandableItem} from '../../WalletInit/WalletInit/ExpandableItem' +import {Spacer} from '../Spacer' interface Props { children: ReactNode } @@ -36,21 +40,74 @@ export class ErrorBoundary extends Component { render() { if (this.state.hasError) { return ( - - Oops!!! Something went wrong.. - Error: {this.state.error} - Error Info: {this.state.errorInfo} + + + + Oops!!! Something went wrong. + + + + + + + + + Please consider sending this error to Yoroi mobile support. Unfortunately, we can not recover from this + error. You need to relaunch the app. + + + + + + + {this.state.error} + + + + + + + + + {Platform.OS === 'android' && ( + +