Skip to content

Commit d7e8766

Browse files
committed
LIVE-3385 - LLM fix undefined issue during receive flow
1 parent d39efbb commit d7e8766

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.changeset/nervous-dingos-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"live-mobile": patch
3+
---
4+
5+
LLM - fix undefined issue on some accounts during receive flow

apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ function AddAccountsAccounts({ navigation, route }: Props) {
9191
const pa = { ...account };
9292

9393
if (
94+
!pa.subAccounts ||
9495
!pa.subAccounts.find(
9596
(a: { token: { id: any } }) => a.token.id === currency.id,
9697
) // in case we dont already have one we create an empty token account
9798
) {
9899
const tokenAcc = makeEmptyTokenAccount(pa, currency);
99100
tokenAcc.parentAccount = pa;
100-
pa.subAccounts.push(tokenAcc);
101+
pa.subAccounts = [...(pa.subAccounts || []), tokenAcc];
101102
}
102103

103104
setScannedAccounts((accs: Account[]) => [...accs, pa]); // add the account with the newly added token account to the list of scanned accounts

apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ function ReceiveSelectAccount({ navigation, route }: Props) {
3737
() =>
3838
currency.type === "TokenCurrency"
3939
? parentAccounts.reduce((accs, pa) => {
40-
const tokenAccounts = pa.subAccounts.filter(
41-
acc => acc.token.id === currency.id,
42-
);
40+
const tokenAccounts = pa.subAccounts
41+
? pa.subAccounts.filter(
42+
(acc: any) => acc.token.id === currency.id,
43+
)
44+
: [];
4345

4446
if (tokenAccounts.length > 0) {
4547
accs.push(...tokenAccounts);

apps/ledger-live-mobile/src/screens/ReceiveFunds/03-Confirmation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ function ReceiveConfirmationInner({ navigation, route, account, parentAccount }:
113113
useEffect(() => {
114114
if(route.params?.createTokenAccount && !hasAddedTokenAccount) {
115115
const newMainAccount = {...mainAccount};
116-
if(!newMainAccount.subAccounts.find((acc: TokenAccount) => acc?.token?.id === currency.id)) {
116+
if(!newMainAccount.subAccounts || !newMainAccount.subAccounts.find((acc: TokenAccount) => acc?.token?.id === currency.id)) {
117117
const emptyTokenAccount = makeEmptyTokenAccount(newMainAccount, currency);
118-
newMainAccount.subAccounts = [...newMainAccount.subAccounts, emptyTokenAccount];
118+
newMainAccount.subAccounts = [...(newMainAccount.subAccounts || []), emptyTokenAccount];
119119

120120
// @TODO create a new action for adding a single account at a time instead of replacing
121121
dispatch(replaceAccounts({ scannedAccounts: [newMainAccount], selectedIds: [newMainAccount.id], renamings: {}}));

0 commit comments

Comments
 (0)