Skip to content

Commit

Permalink
Replace NetworkError instance for the common one
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo committed Apr 23, 2024
1 parent 06b6760 commit 076af12
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {NavigationRouteContext} from '@react-navigation/native'
import {action} from '@storybook/addon-actions'
import {storiesOf} from '@storybook/react-native'
import {NetworkError} from '@yoroi/common'
import React from 'react'

import {WalletManager, walletManager} from '../../../../wallet-manager/walletManager'
import {WalletManagerProvider} from '../../../../wallet-manager/WalletManagerContext'
import {NetworkError} from '../../../../yoroi-wallets/cardano/errors'
import {SaveNanoXScreen} from './SaveNanoXScreen'

storiesOf('SaveNanoXScreen', module)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {NetworkError} from '@yoroi/common'
import {useSetupWallet} from '@yoroi/setup-wallet'
import React from 'react'
import {defineMessages, useIntl} from 'react-intl'
Expand All @@ -9,7 +10,6 @@ import {errorMessages} from '../../../../i18n/global-messages'
import {useMetrics} from '../../../../metrics/metricsManager'
import {useWalletNavigation} from '../../../../navigation'
import {AddressMode} from '../../../../wallet-manager/types'
import {NetworkError} from '../../../../yoroi-wallets/cardano/errors'
import {useCreateBip44Wallet} from '../../../../yoroi-wallets/hooks'
import {WalletImplementationId} from '../../../../yoroi-wallets/types'
import {WalletNameForm} from '../WalletNameForm/WalletNameForm'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {NavigationRouteContext} from '@react-navigation/native'
import {action} from '@storybook/addon-actions'
import {storiesOf} from '@storybook/react-native'
import {NetworkError} from '@yoroi/common'
import React from 'react'

import {WalletManager, walletManager} from '../../../../wallet-manager/walletManager'
import {WalletManagerProvider} from '../../../../wallet-manager/WalletManagerContext'
import {NetworkError} from '../../../../yoroi-wallets/cardano/errors'
import {SaveReadOnlyWalletScreen} from './SaveReadOnlyWalletScreen'

storiesOf('SaveReadOnlyWalletScreen', module)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {NetworkError} from '@yoroi/common'
import {useSetupWallet} from '@yoroi/setup-wallet'
import React from 'react'
import {defineMessages, useIntl} from 'react-intl'
Expand All @@ -12,7 +13,6 @@ import {useWalletNavigation} from '../../../../navigation'
import {theme} from '../../../../theme'
import {isEmptyString} from '../../../../utils/utils'
import {AddressMode} from '../../../../wallet-manager/types'
import {NetworkError} from '../../../../yoroi-wallets/cardano/errors'
import {NUMBERS} from '../../../../yoroi-wallets/cardano/numbers'
import {useCreateBip44Wallet, usePlate} from '../../../../yoroi-wallets/hooks'
import {NetworkId, WalletImplementationId} from '../../../../yoroi-wallets/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useFocusEffect} from '@react-navigation/native'
import {useAsyncStorage} from '@yoroi/common'
import {NetworkError, useAsyncStorage} from '@yoroi/common'
import {useSetupWallet} from '@yoroi/setup-wallet'
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
Expand Down Expand Up @@ -27,7 +27,7 @@ import {isEmptyString} from '../../../../utils'
import {AddressMode} from '../../../../wallet-manager/types'
import {parseWalletMeta} from '../../../../wallet-manager/validators'
import {useWalletManager} from '../../../../wallet-manager/WalletManagerContext'
import {InvalidState, NetworkError} from '../../../../yoroi-wallets/cardano/errors'
import {InvalidState} from '../../../../yoroi-wallets/cardano/errors'
import {useCreateWallet, useOpenWallet, usePlate, useWalletNames} from '../../../../yoroi-wallets/hooks'
import {WalletImplementationId} from '../../../../yoroi-wallets/types'
import {
Expand Down Expand Up @@ -233,7 +233,7 @@ export const WalletDetailsScreen = () => {
])

React.useEffect(() => {
if (showRestoreWalletInfoModal) showModalTipsPassword()
if (showRestoreWalletInfoModal === true) showModalTipsPassword()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showRestoreWalletInfoModal])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useFocusEffect} from '@react-navigation/native'
import {useAsyncStorage} from '@yoroi/common'
import {NetworkError, useAsyncStorage} from '@yoroi/common'
import {useSetupWallet} from '@yoroi/setup-wallet'
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
Expand Down Expand Up @@ -28,7 +28,7 @@ import {isEmptyString} from '../../../../utils'
import {AddressMode} from '../../../../wallet-manager/types'
import {parseWalletMeta} from '../../../../wallet-manager/validators'
import {useWalletManager} from '../../../../wallet-manager/WalletManagerContext'
import {InvalidState, NetworkError} from '../../../../yoroi-wallets/cardano/errors'
import {InvalidState} from '../../../../yoroi-wallets/cardano/errors'
import {useCreateWallet, useOpenWallet, usePlate, useWalletNames} from '../../../../yoroi-wallets/hooks'
import {WalletImplementationId} from '../../../../yoroi-wallets/types'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useFocusEffect, useNavigation} from '@react-navigation/native'
import {NetworkError} from '@yoroi/common'
import {useSetupWallet} from '@yoroi/setup-wallet'
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
Expand All @@ -16,7 +17,7 @@ import {useWalletNavigation} from '../../../navigation'
import {WalletMeta} from '../../../wallet-manager/types'
import {useWalletManager} from '../../../wallet-manager/WalletManagerContext'
import * as HASKELL_SHELLEY from '../../../yoroi-wallets/cardano/constants/mainnet/constants'
import {InvalidState, NetworkError} from '../../../yoroi-wallets/cardano/errors'
import {InvalidState} from '../../../yoroi-wallets/cardano/errors'
import {isJormungandr} from '../../../yoroi-wallets/cardano/networks'
import {useOpenWallet, useWalletMetas} from '../../../yoroi-wallets/hooks'
import {useLinksRequestWallet} from '../../Links/common/useLinksRequestWallet'
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-mobile/src/legacy/DeveloperScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import AsyncStorage from '@react-native-async-storage/async-storage'
import {useNavigation} from '@react-navigation/native'
import {NetworkError} from '@yoroi/common'
import {useTheme} from '@yoroi/theme'
import assert from 'assert'
import ExtendableError from 'es6-error'
Expand All @@ -19,7 +20,6 @@ import {errorMessages} from '../i18n/global-messages'
import {storageVersionMaker} from '../migrations/storageVersion'
import {AppRoutes, useWalletNavigation} from '../navigation'
import {isEmptyString} from '../utils/utils'
import {NetworkError} from '../yoroi-wallets/cardano/errors'
import {generateAdaMnemonic} from '../yoroi-wallets/cardano/mnemonic'
import {useCreateWallet} from '../yoroi-wallets/hooks'
import {rootStorage} from '../yoroi-wallets/storage/rootStorage'
Expand Down
3 changes: 2 additions & 1 deletion apps/wallet-mobile/src/yoroi-wallets/cardano/api/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {NetworkError} from '@yoroi/common'
import {Platform} from 'react-native'
import DeviceInfo from 'react-native-device-info'

import {Logger} from '../../logging'
import type {BackendConfig} from '../../types/other'
import {ApiError, ApiHistoryError, NetworkError} from '../errors'
import {ApiError, ApiHistoryError} from '../errors'

type RequestMethod = 'POST' | 'GET'

Expand Down
10 changes: 0 additions & 10 deletions apps/wallet-mobile/src/yoroi-wallets/cardano/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ export class ApiError extends LocalizableError {
}
}

// thrown when api failed to connect to the server
export class NetworkError extends LocalizableError {
constructor() {
super({
id: errorMessages.networkError.message.id,
defaultMessage: errorMessages.networkError.message.defaultMessage || '',
})
}
}

// thrown by the backend after a rollback
export class ApiHistoryError extends ApiError {
public static readonly errors = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"start": {
"line": 80,
"column": 30,
"index": 2604
"index": 2577
},
"end": {
"line": 83,
"column": 3,
"index": 2741
"index": 2714
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"start": {
"line": 143,
"column": 21,
"index": 4260
"index": 4233
},
"end": {
"line": 146,
"column": 3,
"index": 4387
"index": 4360
}
},
{
Expand All @@ -21,12 +21,12 @@
"start": {
"line": 147,
"column": 17,
"index": 4406
"index": 4379
},
"end": {
"line": 150,
"column": 3,
"index": 4520
"index": 4493
}
},
{
Expand All @@ -36,12 +36,12 @@
"start": {
"line": 151,
"column": 22,
"index": 4544
"index": 4517
},
"end": {
"line": 154,
"column": 3,
"index": 4668
"index": 4641
}
},
{
Expand All @@ -51,12 +51,12 @@
"start": {
"line": 155,
"column": 7,
"index": 4677
"index": 4650
},
"end": {
"line": 158,
"column": 3,
"index": 4775
"index": 4748
}
},
{
Expand All @@ -66,12 +66,12 @@
"start": {
"line": 159,
"column": 18,
"index": 4795
"index": 4768
},
"end": {
"line": 162,
"column": 3,
"index": 4916
"index": 4889
}
}
]

0 comments on commit 076af12

Please sign in to comment.