Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2e288d9
refactor ledger add account UI
ruijialin-avalabs Feb 11, 2026
fc73bf7
update state
ruijialin-avalabs Feb 11, 2026
b2afc53
cancel
ruijialin-avalabs Feb 11, 2026
e814503
show loading when no device id
ruijialin-avalabs Feb 11, 2026
bcee392
add resetSetup
ruijialin-avalabs Feb 12, 2026
23869c5
refactor ledger context
ruijialin-avalabs Feb 12, 2026
5150db8
refactor useLedgerDeviceInfo
ruijialin-avalabs Feb 12, 2026
d2cd98b
use useLedgerWalletMap for quicker access
ruijialin-avalabs Feb 12, 2026
b0e6f72
add missing ledger store
ruijialin-avalabs Feb 12, 2026
2cd4677
remove useObserveLedgerState
ruijialin-avalabs Feb 12, 2026
fa8f9eb
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 12, 2026
b4a049f
fix typos
ruijialin-avalabs Feb 12, 2026
7ffdbcb
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 12, 2026
88c2d86
add comment
ruijialin-avalabs Feb 12, 2026
2739a3c
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 12, 2026
22732fb
copilot comments
ruijialin-avalabs Feb 12, 2026
59160b1
remove unneccessary resetSetup()
ruijialin-avalabs Feb 12, 2026
fc5cfe3
ensure ledgerlive type safetyg
ruijialin-avalabs Feb 12, 2026
87d2375
copilot comments
ruijialin-avalabs Feb 12, 2026
5dc4592
ensure connection for handle solana as wellg
ruijialin-avalabs Feb 12, 2026
2613dd8
copilot comments
ruijialin-avalabs Feb 13, 2026
2a85f59
copilot comments
ruijialin-avalabs Feb 13, 2026
1211098
accounts nullish check
ruijialin-avalabs Feb 13, 2026
53f63e2
fix testnet/mainnet address
ruijialin-avalabs Feb 13, 2026
9d2db19
fix lint
ruijialin-avalabs Feb 13, 2026
19d3e98
fix incorrect btc addr
ruijialin-avalabs Feb 13, 2026
3916830
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 13, 2026
e3c43a4
pr comments
ruijialin-avalabs Feb 13, 2026
33b0205
add back publicKeysg
ruijialin-avalabs Feb 13, 2026
4c47039
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 13, 2026
6ca2dee
copilot comments
ruijialin-avalabs Feb 13, 2026
407feae
set device info for consistency
ruijialin-avalabs Feb 13, 2026
f9ff67d
pr comment
ruijialin-avalabs Feb 13, 2026
822de7e
add missgin array dep
ruijialin-avalabs Feb 16, 2026
f290afc
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 16, 2026
f362502
copilot comments
ruijialin-avalabs Feb 16, 2026
6817187
Merge branch 'main' into cp-13334
ruijialin-avalabs Feb 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 28 additions & 37 deletions packages/core-mobile/app/new/common/components/WalletCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useManageWallet } from 'common/hooks/useManageWallet'
import { AccountDisplayData, WalletDisplayData } from 'common/types'
import { AccountListItem } from 'features/wallets/components/AccountListItem'
import { WalletBalance } from 'features/wallets/components/WalletBalance'
import React, { useCallback, useState } from 'react'
import React, { useCallback, useMemo, useState } from 'react'
import {
FlatList,
LayoutChangeEvent,
Expand All @@ -22,9 +22,6 @@ import {
} from 'react-native'
import Animated, { useAnimatedStyle, withTiming } from 'react-native-reanimated'
import { WalletType } from 'services/wallet/types'
import { LedgerAppType } from 'services/ledger/types'
import { LedgerConnectionCaption } from 'features/accountSettings/components/LedgerConnectionCaption'
import { useObserveLedgerState } from 'common/hooks/useObserveLedgerState'
import { DropdownMenu } from './DropdownMenu'
import { WalletIcon } from './WalletIcon'

Expand Down Expand Up @@ -58,10 +55,12 @@ const WalletCard = ({
isAddingAccount
} = useManageWallet()

const { isAppOpened, isLedger } = useObserveLedgerState(
wallet.id,
LedgerAppType.AVALANCHE
)
const isLedger = useMemo(() => {
return (
wallet?.type === WalletType.LEDGER_LIVE ||
wallet?.type === WalletType.LEDGER
)
}, [wallet?.type])

const renderExpansionIcon = useCallback(() => {
return (
Expand All @@ -84,7 +83,7 @@ const WalletCard = ({
/>
)
},
[isRefreshing]
[isRefreshing, wallet.name]
)

const renderEmpty = useCallback(() => {
Expand Down Expand Up @@ -153,34 +152,26 @@ const WalletCard = ({
/>

{wallet.type !== WalletType.PRIVATE_KEY ? (
<View sx={{ gap: 16 }}>
{((isLedger && isAppOpened) || !isLedger) && (
<Button
testID={`add_account_btn__${wallet.name}`}
size="medium"
leftIcon={
isAddingAccount ? undefined : (
<Icons.Content.Add
color={colors.$textPrimary}
width={24}
height={24}
/>
)
}
type="secondary"
disabled={isAddingAccount}
onPress={() => handleAddAccountToWallet(wallet)}>
{isAddingAccount ? (
<ActivityIndicator size="small" color={colors.$textPrimary} />
) : (
'Add account'
)}
</Button>
)}
{isLedger && !isAppOpened && (
<LedgerConnectionCaption appType={LedgerAppType.AVALANCHE} />
<Button
size="medium"
leftIcon={
isAddingAccount ? undefined : (
<Icons.Content.Add
color={colors.$textPrimary}
width={24}
height={24}
/>
)
}
type="secondary"
disabled={isAddingAccount}
onPress={() => handleAddAccountToWallet(wallet)}>
{isAddingAccount ? (
<ActivityIndicator size="small" color={colors.$textPrimary} />
) : (
'Add account'
)}
</View>
</Button>
) : (
<></>
)}
Expand Down Expand Up @@ -277,7 +268,7 @@ const WalletCard = ({
groups={[
{
key: 'wallet-actions',
items: getDropdownItems(wallet, isLedger && isAppOpened)
items: getDropdownItems(wallet, isLedger)
}
]}
onPressAction={(event: { nativeEvent: { event: string } }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { resetLoginAttempt } from 'store/security'
export const useDeleteWallet = (): {
deleteWallet: () => void
} => {
const { resetLedgerWalletMap } = useLedgerWalletMap()
const { deleteRecentAccounts } = useRecentAccounts()
const dispatch = useDispatch()
const { resetLedgerWalletMap } = useLedgerWalletMap()

const deleteWallet = useCallback(() => {
dispatch(onLogOut())
Expand Down
20 changes: 17 additions & 3 deletions packages/core-mobile/app/new/common/hooks/useManageWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
dismissAlertWithTextInput,
showAlertWithTextInput
} from 'common/utils/alertWithTextInput'
import { useLedgerWalletMap } from 'features/ledger/store'
import { useRouter } from 'expo-router'
import { showSnackbar } from 'new/common/utils/toast'
import { useCallback, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
Expand All @@ -22,6 +22,7 @@ import {
import { removeWallet } from 'store/wallet/thunks'
import { Wallet } from 'store/wallet/types'
import Logger from 'utils/Logger'
import { useLedgerWalletMap } from 'features/ledger/store'

export const useManageWallet = (): {
handleAddAccount: (wallet: Wallet) => void
Expand All @@ -30,6 +31,7 @@ export const useManageWallet = (): {
isAddingAccount: boolean
} => {
const { removeLedgerWallet } = useLedgerWalletMap()
const { navigate } = useRouter()
const [isAddingAccount, setIsAddingAccount] = useState(false)
const dispatch = useDispatch<AppThunkDispatch>()
const walletsCount = useSelector(selectWalletsCount)
Expand Down Expand Up @@ -115,14 +117,26 @@ export const useManageWallet = (): {
]
})
},
[dispatch, walletsCount, removeLedgerWallet]
[dispatch, removeLedgerWallet, walletsCount]
)

const handleAddAccount = useCallback(
async (wallet: Wallet): Promise<void> => {
if (isAddingAccount) return

try {
if (
wallet.type === WalletType.LEDGER ||
wallet.type === WalletType.LEDGER_LIVE
) {
navigate({
// @ts-ignore TODO: make routes typesafe
pathname: '/addAccountAppConnection',
params: { walletId: wallet.id }
})
return
}

AnalyticsService.capture('AccountSelectorAddAccount', {
accountNumber: Object.keys(accounts).length + 1
})
Expand All @@ -142,7 +156,7 @@ export const useManageWallet = (): {
setIsAddingAccount(false)
}
},
[isAddingAccount, accounts, dispatch]
[isAddingAccount, accounts, dispatch, navigate]
)

const canRemoveWallet = useCallback(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { WalletType } from 'services/wallet/types'
import { useSelector } from 'react-redux'
import { selectIsSolanaSupportBlocked } from 'store/posthog'
import { useRouter } from 'expo-router'
import { LedgerAppType } from 'services/ledger/types'
import { LedgerConnectionCaption } from './LedgerConnectionCaption'

export const AccountAddresses = ({
account
Expand Down Expand Up @@ -94,7 +92,7 @@ export const AccountAddresses = ({
value:
isLedger &&
network.vmName === NetworkVMType.SVM &&
(address === undefined || address === '') &&
isMissingSolanaAddress &&
!isSolanaSupportBlocked ? (
<SolanaEnableButton accountId={account.id} />
) : (
Expand Down Expand Up @@ -140,9 +138,6 @@ export const AccountAddresses = ({
lineHeight: 22
}}
/>
{isMissingSolanaAddress && !isSolanaSupportBlocked && (
<LedgerConnectionCaption appType={LedgerAppType.SOLANA} />
)}
</View>
)
}
Expand Down
Loading
Loading