From 0314822eca3496af13ded2e6b03fb1d2e36bb92f Mon Sep 17 00:00:00 2001 From: heisenberg Date: Thu, 14 Sep 2023 11:27:52 +0800 Subject: [PATCH] fix: ignore error when getting address info on address management page --- src/ui/views/HDManager/AccountList.tsx | 2 +- src/ui/views/HDManager/utils.tsx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ui/views/HDManager/AccountList.tsx b/src/ui/views/HDManager/AccountList.tsx index 17e6e9a68d2..9f532f980d5 100644 --- a/src/ui/views/HDManager/AccountList.tsx +++ b/src/ui/views/HDManager/AccountList.tsx @@ -87,7 +87,7 @@ export const AccountList: React.FC = ({ React.useEffect(() => { if (!hiddenInfo) { - createTask(() => fetchAccountsInfo(wallet, data ?? []).then(setList)); + fetchAccountsInfo(wallet, data ?? []).then(setList); } else { setList(data ?? []); } diff --git a/src/ui/views/HDManager/utils.tsx b/src/ui/views/HDManager/utils.tsx index 89820912fb9..ad418e18b33 100644 --- a/src/ui/views/HDManager/utils.tsx +++ b/src/ui/views/HDManager/utils.tsx @@ -8,6 +8,7 @@ import * as Sentry from '@sentry/browser'; import { KEYRING_CLASS } from '@/constant'; import { useRabbyDispatch } from '@/ui/store'; import { useTranslation } from 'react-i18next'; +import { isFunction } from 'lodash'; export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); @@ -40,7 +41,7 @@ export const fetchAccountsInfo = async ( } } - let chains: Account['chains']; + let chains: Account['chains'] = []; try { chains = await wallet.openapi.usedChainList(account.address); } catch (e) { @@ -59,11 +60,13 @@ export const fetchAccountsInfo = async ( } // find firstTxTime - chains?.forEach((chain: any) => { - if (chain.born_at) { - firstTxTime = Math.min(firstTxTime ?? Infinity, chain.born_at); - } - }); + if (isFunction(chains?.forEach)) { + chains?.forEach((chain: any) => { + if (chain.born_at) { + firstTxTime = Math.min(firstTxTime ?? Infinity, chain.born_at); + } + }); + } const accountInfo: Account = { ...account,