Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into fix/pirvacy-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed May 29, 2024
2 parents 925c03f + 9caa640 commit d525844
Show file tree
Hide file tree
Showing 61 changed files with 1,161 additions and 409 deletions.
4 changes: 3 additions & 1 deletion apps/wallet-mobile/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COMMIT=093dec95a
BUILD_VARIANT=STAGING
SENTRY_DSN=https://[email protected]/4505319746764800

DISABLE_LOGBOX=true
DISABLE_LOGBOX=false

WALLET_1_MNEMONIC=abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon address
WALLET_1_NETWORK_ID=300
Expand All @@ -20,3 +20,5 @@ FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmy
FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km

UNSTOPPABLE_API_KEY=czsajliz-wxgu6tujd1zqq7hey_pclfqhdjsqolsxjfsurgh

LOGGER_FILTER=
2 changes: 1 addition & 1 deletion apps/wallet-mobile/.storybook/storybook.requires.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions apps/wallet-mobile/src/YoroiApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {SelectedWalletProvider} from './features/WalletManager/context/SelectedW
import {SelectedWalletMetaProvider} from './features/WalletManager/context/SelectedWalletMetaContext'
import {WalletManagerProvider} from './features/WalletManager/context/WalletManagerContext'
import {InitApp} from './InitApp'
import {disableLogbox} from './kernel/env'
import {disableLogbox, loggerFilter} from './kernel/env'
import {LanguageProvider} from './kernel/i18n'
import {useSetupLogger} from './kernel/logger/hooks/useSetupLogger'
import {makeMetricsManager, MetricsProvider} from './kernel/metrics/metricsManager'
Expand All @@ -29,7 +29,11 @@ import {useThemeStorageMaker} from './yoroi-wallets/hooks'
enableScreens(true)
enableFreeze(true)

if (disableLogbox) LogBox.ignoreAllLogs()
if (disableLogbox) {
LogBox.ignoreAllLogs()
} else {
LogBox.ignoreLogs(['Require cycle:'])
}

const queryClient = new QueryClient()
const metricsManager = makeMetricsManager()
Expand Down Expand Up @@ -74,7 +78,7 @@ const Yoroi = () => {
}

export const YoroiApp = () => {
const isReady = useSetupLogger()
const isReady = useSetupLogger(loggerFilter)

if (!isReady) return null

Expand Down
24 changes: 0 additions & 24 deletions apps/wallet-mobile/src/features/Exchange/common/useNavigateTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,5 @@ export const useNavigateTo = () => {
return useRef({
exchangeSelectBuyProvider: () => navigation.navigate('exchange-select-buy-provider'),
exchangeSelectSellProvider: () => navigation.navigate('exchange-select-sell-provider'),
exchangeOpenOrder: () =>
navigation.reset({
index: 0,
routes: [
{
name: 'manage-wallets',
state: {
routes: [
{name: 'wallet-selection'},
{
name: 'main-wallet-routes',
state: {
routes: [
{
name: 'history-list',
},
],
},
},
],
},
},
],
}),
}).current
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {Space} from '../../../../components/Space/Space'
import {Warning} from '../../../../components/Warning'
import {banxaTestWallet} from '../../../../kernel/env'
import {useMetrics} from '../../../../kernel/metrics/metricsManager'
import {useWalletNavigation} from '../../../../kernel/navigation'
import {useTokenInfo} from '../../../../yoroi-wallets/hooks'
import {Quantities} from '../../../../yoroi-wallets/utils'
import {useSelectedWallet} from '../../../WalletManager/context/SelectedWalletContext'
Expand All @@ -31,6 +32,7 @@ export const CreateExchangeOrderScreen = () => {
const styles = useStyles()
const {track} = useMetrics()
const wallet = useSelectedWallet()
const walletNavigation = useWalletNavigation()
const [contentHeight, setContentHeight] = React.useState(0)

const navigateTo = useNavigateTo()
Expand Down Expand Up @@ -88,7 +90,7 @@ export const CreateExchangeOrderScreen = () => {
if (referralLink.toString() !== '') {
Linking.openURL(referralLink.toString())
track.exchangeSubmitted({ramp_type: orderType === 'sell' ? 'Sell' : 'Buy', ada_amount: orderAmount})
navigateTo.exchangeOpenOrder()
walletNavigation.navigateToTxHistory()
}
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {RouteProp, useRoute} from '@react-navigation/native'
import {isString} from '@yoroi/common'
import {useExplorers} from '@yoroi/explorers'
import {usePorfolioTokenDiscovery} from '@yoroi/portfolio'
import {usePorfolioTokenDiscovery, usePorfolioTokenTraits} from '@yoroi/portfolio'
import {useTheme} from '@yoroi/theme'
import {Chain, Portfolio} from '@yoroi/types'
import React, {ReactNode, useState} from 'react'
import {defineMessages, useIntl} from 'react-intl'
import {Linking, SafeAreaView, ScrollView, StyleSheet, TouchableOpacity, useWindowDimensions, View} from 'react-native'

import {CopyButton, FadeIn, Spacer, Text} from '../../../../components'
import {Boundary, CopyButton, FadeIn, Spacer, Text} from '../../../../components'
import {Tab, TabPanel, TabPanels, Tabs} from '../../../../components/Tabs'
import {time} from '../../../../kernel/constants'
import {useMetrics} from '../../../../kernel/metrics/metricsManager'
import {NftRoutes} from '../../../../kernel/navigation'
import {useNavigateTo} from '../../../Nfts/common/navigation'
Expand Down Expand Up @@ -65,7 +66,9 @@ export const MediaDetails = () => {
/>
</Tabs>

<Details info={amount.info} activeTab={activeTab} network={network} />
<Boundary>
<Details info={amount.info} activeTab={activeTab} network={network} />
</Boundary>
</ScrollView>
</SafeAreaView>
</FadeIn>
Expand All @@ -88,7 +91,17 @@ const Details = ({activeTab, info, network}: DetailsProps) => {
getTokenDiscovery: api.tokenDiscovery,
},
{
staleTime: Infinity,
staleTime: time.session,
},
)
const {tokenTraits} = usePorfolioTokenTraits(
{
id: info.id,
network,
getTokenTraits: api.tokenTraits,
},
{
staleTime: time.oneDay,
},
)

Expand All @@ -98,7 +111,7 @@ const Details = ({activeTab, info, network}: DetailsProps) => {
return (
<TabPanels>
<TabPanel active={activeTab === 'overview'}>
<NftOverview info={info} network={network} />
<NftOverview info={info} network={network} traits={tokenTraits} />
</TabPanel>

<TabPanel active={activeTab === 'metadata'}>
Expand Down Expand Up @@ -129,7 +142,7 @@ const MetadataRow = ({title, copyText, children}: {title: string; children: Reac
const styles = useStyles()
return (
<View style={styles.rowContainer}>
<View style={styles.rowTitleContainer}>
<View style={styles.rowBetween}>
<Text style={styles.title}>{title}</Text>

{copyText !== undefined ? <CopyButton value={copyText} /> : null}
Expand All @@ -144,9 +157,10 @@ const MetadataRow = ({title, copyText, children}: {title: string; children: Reac

type NftOverviewProps = {
info: Portfolio.Token.Info
traits: Portfolio.Token.Traits | undefined
network: Chain.SupportedNetworks
}
const NftOverview = ({info, network}: NftOverviewProps) => {
const NftOverview = ({info, network, traits}: NftOverviewProps) => {
const styles = useStyles()
const strings = useStrings()
const explorers = useExplorers(network)
Expand All @@ -171,6 +185,16 @@ const NftOverview = ({info, network}: NftOverviewProps) => {
<Text style={styles.name}>{policyId}</Text>
</MetadataRow>

{traits?.traits.map((trait) => (
<MetadataRow key={`${info.id}-trait-${trait.type}`} title={trait.type}>
<View style={styles.rowBetween}>
<Text style={styles.name}>{trait.value}</Text>

<Text style={styles.name}>{trait.rarity}</Text>
</View>
</MetadataRow>
))}

<MetadataRow title={strings.detailsLinks}>
<View
style={{
Expand Down Expand Up @@ -283,7 +307,7 @@ const useStyles = () => {
rowContainer: {
paddingVertical: imagePadding,
},
rowTitleContainer: {
rowBetween: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react'
import {defineMessages, useIntl} from 'react-intl'

import {defaultStackNavigationOptions, WalletInitRoutes} from '../../kernel/navigation'
import {PreparingWalletScreen} from './common/PreparingWalletScreen/PreparingWalletScreen'
import {CheckNanoXScreen} from './legacy/CheckNanoX/CheckNanoXScreen'
import {ConnectNanoXScreen} from './legacy/ConnectNanoX/ConnectNanoXScreen'
import {ImportReadOnlyWalletScreen} from './legacy/ImportReadOnlyWallet/ImportReadOnlyWalletScreen'
Expand Down Expand Up @@ -134,6 +135,12 @@ export const SetupWalletNavigator = () => {
component={VerifyRecoveryPhraseScreen}
options={{title: strings.createWalletTitle}}
/>

<Stack.Screen
name="setup-wallet-preparing-wallet"
component={PreparingWalletScreen}
options={{headerShown: false}}
/>
</Stack.Navigator>
)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {storiesOf} from '@storybook/react-native'
import React from 'react'
import {StyleSheet, View} from 'react-native'

import {PreparingWallet} from './PreparingWallet'
import {PreparingWalletScreen} from './PreparingWalletScreen'

storiesOf('AddWallet PreparingWallet', module)
.addDecorator((story) => <View style={styles.container}>{story()}</View>)
.add('initial', () => <PreparingWallet />)
.add('initial', () => <PreparingWalletScreen />)

const styles = StyleSheet.create({
container: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {useSetupWallet} from '@yoroi/setup-wallet'
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
import {StyleSheet, Text} from 'react-native'
import {SafeAreaView} from 'react-native-safe-area-context'

import {logger} from '../../../../kernel/logger/logger'
import {isEmptyString} from '../../../../kernel/utils'
import {useLaunchWalletAfterSyncing} from '../../../WalletManager/common/useLaunchWalletAfterSyncing'
import {useSyncTemporarilyPaused} from '../../../WalletManager/common/useSyncTemporarilyPaused'
import {useStrings} from '../useStrings'

/**
* It requests the global syncing to stop on mounting to favor the sync of a specific wallet
* and resume the global syncing after the wallet is sync and the screen is unmounted.
*/
export const PreparingWalletScreen = () => {
const strings = useStrings()
const {styles} = useStyles()
const {walletId} = useSetupWallet()
const isGlobalSyncPaused = useSyncTemporarilyPaused()
useLaunchWalletAfterSyncing({isGlobalSyncPaused, walletId})

if (isEmptyString(walletId)) {
const error = new Error('PreparingWalletScreen: walletId is empty, reached an invalid state.')
logger.error(error)
throw error
}

return (
<SafeAreaView edges={['left', 'right', 'bottom', 'top']} style={styles.root}>
<Text style={styles.title}>{strings.preparingWallet}</Text>
</SafeAreaView>
)
}

const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
root: {
...atoms.flex_1,
...atoms.align_center,
...atoms.justify_center,
},
title: {
color: color.primary_c500,
...atoms.text_center,
...atoms.heading_2_medium,
},
})
return {styles} as const
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {SafeAreaView} from 'react-native-safe-area-context'
import image from '../../../../assets/img/ledger_1.png'
import {BulletPointItem, Button, ProgressStep, Spacer, Text} from '../../../../components'
import {confirmationMessages, ledgerMessages} from '../../../../kernel/i18n/global-messages'
import {WalletInitRouteNavigation} from '../../../../kernel/navigation'
import {SetupWalletRouteNavigation} from '../../../../kernel/navigation'

export const CheckNanoXScreen = () => {
const strings = useStrings()
const styles = useStyles()

const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const onContinue = () => navigation.navigate('setup-wallet-connect-nano-x')
const {useUSB} = useSetupWallet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ProgressStep} from '../../../../components'
import {showErrorDialog} from '../../../../kernel/dialogs'
import {errorMessages} from '../../../../kernel/i18n/global-messages'
import LocalizableError from '../../../../kernel/i18n/LocalizableError'
import {WalletInitRouteNavigation} from '../../../../kernel/navigation'
import {SetupWalletRouteNavigation} from '../../../../kernel/navigation'
import {LedgerConnect} from '../../../../legacy/HW'
import {getHWDeviceInfo} from '../../../../yoroi-wallets/cardano/hw'
import {DeviceId, DeviceObj, HWDeviceInfo} from '../../../../yoroi-wallets/hw'
Expand All @@ -30,7 +30,7 @@ export const ConnectNanoXScreen = ({defaultDevices}: Props) => {
const intl = useIntl()
const strings = useStrings()
const styles = useStyles()
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()

const {hwDeviceInfoChanged, walletImplementationId, useUSB} = useSetupWallet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {BulletPointItem, CameraCodeScanner, Spacer, Text} from '../../../../comp
import {showErrorDialog} from '../../../../kernel/dialogs'
import {errorMessages} from '../../../../kernel/i18n/global-messages'
import {logger} from '../../../../kernel/logger/logger'
import {WalletInitRouteNavigation} from '../../../../kernel/navigation'
import {SetupWalletRouteNavigation} from '../../../../kernel/navigation'
import {isCIP1852AccountPath, isValidPublicKey} from '../../../../yoroi-wallets/cardano/bip44Validators'

export const ImportReadOnlyWalletScreen = () => {
const intl = useIntl()
const strings = useStrings()
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const {publicKeyHexChanged, pathChanged} = useSetupWallet()

const onRead = async (event: {data: string}): Promise<boolean> => {
Expand Down
Loading

0 comments on commit d525844

Please sign in to comment.