From a38ddb371a08a122aa68e2162164d50156533dec Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Mon, 3 Mar 2025 16:38:22 +0100 Subject: [PATCH 1/3] Use explorer data when pool info is missing --- .../src/legacy/Dashboard/StakePoolInfo.tsx | 20 +++++- .../changeAppSettings/About/About.json | 71 +++++++++++-------- .../src/legacy/Dashboard/StakePoolInfo.json | 40 +++++------ 3 files changed, 82 insertions(+), 49 deletions(-) diff --git a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx index 5c7a7424e7..d5a02a9278 100644 --- a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx +++ b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx @@ -1,3 +1,4 @@ +import {PoolInfoApi} from '@emurgo/yoroi-lib' import {useTheme} from '@yoroi/theme' import React from 'react' import {defineMessages, useIntl} from 'react-intl' @@ -8,6 +9,7 @@ import {Button, ButtonType} from '../../components/Button/Button' import {CopyButton} from '../../components/CopyButton' import {Text} from '../../components/Text' import {TitledCard} from '../../components/TitledCard' +import {useSelectedNetwork} from '../../features/WalletManager/common/hooks/useSelectedNetwork' import {useSelectedWallet} from '../../features/WalletManager/common/hooks/useSelectedWallet' import {isEmptyString} from '../../kernel/utils' import {YoroiWallet} from '../../yoroi-wallets/cardano/types' @@ -63,13 +65,29 @@ export const useStakePoolInfoAndHistory = ( [string, string, string] >, ) => { + const {networkManager} = useSelectedNetwork() + const poolInfoApi = React.useMemo( + () => new PoolInfoApi(networkManager.legacyApiBaseUrl), + [networkManager.legacyApiBaseUrl], + ) const query = useQuery({ ...options, queryKey: [wallet.id, 'stakePoolInfo', stakePoolId], queryFn: async () => { const stakePoolInfosAndHistories = await wallet.fetchPoolInfo({poolIds: [stakePoolId]}) - return stakePoolInfosAndHistories[stakePoolId] + if (stakePoolInfosAndHistories[stakePoolId]?.info?.name != null) return stakePoolInfosAndHistories[stakePoolId] + if (stakePoolInfosAndHistories[stakePoolId]?.history == null) return null + + const explorerPoolInfo = await poolInfoApi.getSingleExplorerPoolInfo(stakePoolId) + + return { + history: stakePoolInfosAndHistories[stakePoolId].history, + info: { + name: explorerPoolInfo?.name ?? '', + ticker: explorerPoolInfo?.ticker ?? '', + }, + } }, }) diff --git a/apps/wallet-mobile/translations/messages/src/features/Settings/useCases/changeAppSettings/About/About.json b/apps/wallet-mobile/translations/messages/src/features/Settings/useCases/changeAppSettings/About/About.json index 5014eda66b..e92863dcc4 100644 --- a/apps/wallet-mobile/translations/messages/src/features/Settings/useCases/changeAppSettings/About/About.json +++ b/apps/wallet-mobile/translations/messages/src/features/Settings/useCases/changeAppSettings/About/About.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Current Version", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 122, + "line": 123, "column": 18, - "index": 3240 + "index": 3312 }, "end": { - "line": 125, + "line": 126, "column": 3, - "index": 3320 + "index": 3392 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!Commit", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 126, + "line": 127, "column": 10, - "index": 3332 + "index": 3404 }, "end": { - "line": 129, + "line": 130, "column": 3, - "index": 3395 + "index": 3467 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Network", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 130, + "line": 131, "column": 11, - "index": 3408 + "index": 3480 }, "end": { - "line": 133, + "line": 134, "column": 3, - "index": 3473 + "index": 3545 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Wallet type", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 134, + "line": 135, "column": 14, - "index": 3489 + "index": 3561 }, "end": { - "line": 137, + "line": 138, "column": 3, - "index": 3600 + "index": 3672 } }, { @@ -64,14 +64,14 @@ "defaultMessage": "!!!Byron-era wallet", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 138, + "line": 139, "column": 15, - "index": 3617 + "index": 3689 }, "end": { - "line": 141, + "line": 142, "column": 3, - "index": 3728 + "index": 3800 } }, { @@ -79,14 +79,14 @@ "defaultMessage": "!!!Shelley-era wallet", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 142, + "line": 143, "column": 17, - "index": 3747 + "index": 3819 }, "end": { - "line": 145, + "line": 146, "column": 3, - "index": 3862 + "index": 3934 } }, { @@ -94,14 +94,29 @@ "defaultMessage": "!!!Unknown Wallet Type", "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", "start": { - "line": 146, + "line": 147, "column": 21, - "index": 3885 + "index": 3957 + }, + "end": { + "line": 150, + "column": 3, + "index": 4077 + } + }, + { + "id": "components.settings.walletsettingscreen.fcmToken", + "defaultMessage": "!!!FCM Token", + "file": "src/features/Settings/useCases/changeAppSettings/About/About.tsx", + "start": { + "line": 151, + "column": 12, + "index": 4091 }, "end": { - "line": 149, + "line": 154, "column": 3, - "index": 4005 + "index": 4192 } } ] \ No newline at end of file diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json index f8e93184c7..27c781210a 100644 --- a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json +++ b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Stake pool delegated", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 105, + "line": 123, "column": 9, - "index": 3212 + "index": 3989 }, "end": { - "line": 108, + "line": 126, "column": 3, - "index": 3333 + "index": 4110 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!If you just delegated to a new stake pool it may take a couple of minutes for the network to process your request.", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 109, + "line": 127, "column": 11, - "index": 3346 + "index": 4123 }, "end": { - "line": 114, + "line": 132, "column": 3, - "index": 3581 + "index": 4358 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Go to website", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 115, + "line": 133, "column": 26, - "index": 3609 + "index": 4386 }, "end": { - "line": 118, + "line": 136, "column": 3, - "index": 3744 + "index": 4521 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Copied!", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 119, + "line": 137, "column": 10, - "index": 3756 + "index": 4533 }, "end": { - "line": 122, + "line": 140, "column": 3, - "index": 3865 + "index": 4642 } }, { @@ -64,14 +64,14 @@ "defaultMessage": "!!!Unknown pool", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 123, + "line": 141, "column": 15, - "index": 3882 + "index": 4659 }, "end": { - "line": 126, + "line": 144, "column": 3, - "index": 4001 + "index": 4778 } } ] \ No newline at end of file From bc41095a00199562c7811e7d84cbad2dc94a10c9 Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Tue, 4 Mar 2025 11:22:17 +0100 Subject: [PATCH 2/3] load lazy --- .../legacy/Dashboard/DashboardNavigator.tsx | 2 +- .../src/legacy/Dashboard/StakePoolInfo.tsx | 3 +- .../src/legacy/Dashboard/StakePoolInfos.tsx | 4 +- .../legacy/Dashboard/DashboardNavigator.json | 4 +- .../src/legacy/Dashboard/StakePoolInfo.json | 40 +++++++++---------- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/apps/wallet-mobile/src/legacy/Dashboard/DashboardNavigator.tsx b/apps/wallet-mobile/src/legacy/Dashboard/DashboardNavigator.tsx index 48e88cd095..bafa263e4e 100644 --- a/apps/wallet-mobile/src/legacy/Dashboard/DashboardNavigator.tsx +++ b/apps/wallet-mobile/src/legacy/Dashboard/DashboardNavigator.tsx @@ -33,7 +33,7 @@ export const DashboardNavigator = () => { > Dashboard} options={{ title: meta.name, }} diff --git a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx index d5a02a9278..4bf7e5c90e 100644 --- a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx +++ b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx @@ -18,11 +18,12 @@ import {StakePoolInfoAndHistory} from '../../yoroi-wallets/types/staking' export const StakePoolInfo = ({stakePoolId}: {stakePoolId: string}) => { const strings = useStrings() const styles = useStyles() + const {isDark} = useTheme() const {wallet} = useSelectedWallet() const {stakePoolInfoAndHistory, isLoading} = useStakePoolInfoAndHistory({wallet, stakePoolId}) const homepage = stakePoolInfoAndHistory?.info?.homepage - if (isLoading) return + if (isLoading) return if (!stakePoolInfoAndHistory?.info) return null return ( diff --git a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx index d0fa9468dd..dd5cde648f 100644 --- a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx +++ b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx @@ -1,3 +1,4 @@ +import {useTheme} from '@yoroi/theme' import {Balance, Wallet} from '@yoroi/types' import BigNumber from 'bignumber.js' import React from 'react' @@ -14,6 +15,7 @@ import {StakePoolInfo} from './StakePoolInfo' export const StakePoolInfos = () => { const {wallet} = useSelectedWallet() const {stakePoolIds, isLoading} = useStakePoolIds(wallet) + const {isDark} = useTheme() return stakePoolIds != null ? ( @@ -23,7 +25,7 @@ export const StakePoolInfos = () => { ) : isLoading ? ( - + ) : null } diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/DashboardNavigator.json b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/DashboardNavigator.json index beb6220f28..0635b791d1 100644 --- a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/DashboardNavigator.json +++ b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/DashboardNavigator.json @@ -6,12 +6,12 @@ "start": { "line": 76, "column": 9, - "index": 2279 + "index": 2288 }, "end": { "line": 79, "column": 3, - "index": 2367 + "index": 2376 } } ] \ No newline at end of file diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json index 27c781210a..d731bb620f 100644 --- a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json +++ b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Stake pool delegated", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 123, + "line": 124, "column": 9, - "index": 3989 + "index": 4040 }, "end": { - "line": 126, + "line": 127, "column": 3, - "index": 4110 + "index": 4161 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!If you just delegated to a new stake pool it may take a couple of minutes for the network to process your request.", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 127, + "line": 128, "column": 11, - "index": 4123 + "index": 4174 }, "end": { - "line": 132, + "line": 133, "column": 3, - "index": 4358 + "index": 4409 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Go to website", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 133, + "line": 134, "column": 26, - "index": 4386 + "index": 4437 }, "end": { - "line": 136, + "line": 137, "column": 3, - "index": 4521 + "index": 4572 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Copied!", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 137, + "line": 138, "column": 10, - "index": 4533 + "index": 4584 }, "end": { - "line": 140, + "line": 141, "column": 3, - "index": 4642 + "index": 4693 } }, { @@ -64,14 +64,14 @@ "defaultMessage": "!!!Unknown pool", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 141, + "line": 142, "column": 15, - "index": 4659 + "index": 4710 }, "end": { - "line": 144, + "line": 145, "column": 3, - "index": 4778 + "index": 4829 } } ] \ No newline at end of file From 931e84014478296db826a545d4fa014cca0f899a Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Tue, 4 Mar 2025 13:46:27 +0100 Subject: [PATCH 3/3] fix tsc --- .../src/legacy/Dashboard/StakePoolInfo.tsx | 6 ++- .../src/legacy/Dashboard/StakePoolInfo.json | 40 +++++++++---------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx index 4bf7e5c90e..a53ee5c93a 100644 --- a/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx +++ b/apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx @@ -78,12 +78,14 @@ export const useStakePoolInfoAndHistory = ( const stakePoolInfosAndHistories = await wallet.fetchPoolInfo({poolIds: [stakePoolId]}) if (stakePoolInfosAndHistories[stakePoolId]?.info?.name != null) return stakePoolInfosAndHistories[stakePoolId] - if (stakePoolInfosAndHistories[stakePoolId]?.history == null) return null + + const history = stakePoolInfosAndHistories[stakePoolId]?.history + if (history == null) return null const explorerPoolInfo = await poolInfoApi.getSingleExplorerPoolInfo(stakePoolId) return { - history: stakePoolInfosAndHistories[stakePoolId].history, + history, info: { name: explorerPoolInfo?.name ?? '', ticker: explorerPoolInfo?.ticker ?? '', diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json index d731bb620f..3bf480f19b 100644 --- a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json +++ b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/StakePoolInfo.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Stake pool delegated", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 124, + "line": 126, "column": 9, - "index": 4040 + "index": 4022 }, "end": { - "line": 127, + "line": 129, "column": 3, - "index": 4161 + "index": 4143 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!If you just delegated to a new stake pool it may take a couple of minutes for the network to process your request.", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 128, + "line": 130, "column": 11, - "index": 4174 + "index": 4156 }, "end": { - "line": 133, + "line": 135, "column": 3, - "index": 4409 + "index": 4391 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Go to website", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 134, + "line": 136, "column": 26, - "index": 4437 + "index": 4419 }, "end": { - "line": 137, + "line": 139, "column": 3, - "index": 4572 + "index": 4554 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Copied!", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 138, + "line": 140, "column": 10, - "index": 4584 + "index": 4566 }, "end": { - "line": 141, + "line": 143, "column": 3, - "index": 4693 + "index": 4675 } }, { @@ -64,14 +64,14 @@ "defaultMessage": "!!!Unknown pool", "file": "src/legacy/Dashboard/StakePoolInfo.tsx", "start": { - "line": 142, + "line": 144, "column": 15, - "index": 4710 + "index": 4692 }, "end": { - "line": 145, + "line": 147, "column": 3, - "index": 4829 + "index": 4811 } } ] \ No newline at end of file