From 443080917b8c772010bfe6fa7212f0541479167f Mon Sep 17 00:00:00 2001 From: banklesss Date: Tue, 17 Dec 2024 13:12:54 +0100 Subject: [PATCH] fix(wallet-mobile): tx review wrong reference inputs display --- .../ReviewTx/common/hooks/useFormattedTx.tsx | 8 +++-- .../features/ReviewTx/common/operations.tsx | 18 +---------- .../ReviewTx/Overview/OverviewTab.tsx | 20 +++++++----- .../messages/src/AppNavigator.json | 32 +++++++++---------- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedTx.tsx b/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedTx.tsx index 2486d78a9c..9d1e97a0ef 100644 --- a/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedTx.tsx +++ b/apps/wallet-mobile/src/features/ReviewTx/common/hooks/useFormattedTx.tsx @@ -90,7 +90,7 @@ export const useFormattedInputs = ( inputUtxos: ReturnType, ) => { const query = useQuery( - ['useFormattedInputs', inputs], + ['useFormattedInputs', inputs, inputUtxos], async () => formatInputs(wallet, inputs, tokenInfosResult, inputUtxos), { suspense: true, @@ -124,6 +124,8 @@ const formatInputs = async ( portfolioTokenInfos: ReturnType, inputUtxos: ReturnType, ): Promise => { + if (inputUtxos.length === 0) return Promise.resolve([]) + return Promise.all( inputs.map(async (input) => { const receiveUTxO = inputUtxos.find( @@ -309,7 +311,9 @@ const getUtxo = async (wallet: YoroiWallet, txHash: string, txIndex: number, get if (!internalUtxo) { const externalUtxo = await getUtxoData({txHash, txIndex}) - return externalUtxo != null ? toRawUtxo(externalUtxo, txHash, txIndex) : null + if (externalUtxo == null) throw new Error('useUtxos: utxo not found') + + return toRawUtxo(externalUtxo, txHash, txIndex) } return internalUtxo diff --git a/apps/wallet-mobile/src/features/ReviewTx/common/operations.tsx b/apps/wallet-mobile/src/features/ReviewTx/common/operations.tsx index 7e67d04739..e955379508 100644 --- a/apps/wallet-mobile/src/features/ReviewTx/common/operations.tsx +++ b/apps/wallet-mobile/src/features/ReviewTx/common/operations.tsx @@ -297,7 +297,6 @@ export type Operations = { component: React.ReactNode }> totalFee: Balance.Quantity - operationCount: OperationsCount } export const useOperations = (certificates: FormattedTx['certificates']) => { const {wallet} = useSelectedWallet() @@ -307,7 +306,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { return { components: [] as Operations['components'], totalFee: Quantities.zero, - operationCount, } const certificatesTypes = certificates.map((cert) => cert.type) @@ -341,7 +339,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: Quantities.sum([fee, acc.totalFee]), - operationCount, } } @@ -362,7 +359,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } case CertificateType.StakeDelegation: { @@ -385,7 +381,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -409,7 +404,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } if (drep === 'AlwaysNoConfidence') return { @@ -428,7 +422,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } const drepId = ('KeyHash' in drep ? drep.KeyHash : drep.ScriptHash) ?? '' @@ -449,7 +442,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -472,7 +464,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: Quantities.sum([fee, acc.totalFee]), - operationCount, } } @@ -493,7 +484,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -516,7 +506,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: Quantities.sum([fee, acc.totalFee]), - operationCount, } } @@ -537,7 +526,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -558,7 +546,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -579,7 +566,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -600,7 +586,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -621,7 +606,6 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { }, ], totalFee: acc.totalFee, - operationCount, } } @@ -629,7 +613,7 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { return acc } }, - {components: [], totalFee: Quantities.zero, operationCount: {} as OperationsCount}, + {components: [], totalFee: Quantities.zero}, ) } diff --git a/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTx/Overview/OverviewTab.tsx b/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTx/Overview/OverviewTab.tsx index 2d916eb673..e4cc8cea70 100644 --- a/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTx/Overview/OverviewTab.tsx +++ b/apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/ReviewTx/Overview/OverviewTab.tsx @@ -43,13 +43,16 @@ export const OverviewTab = ({ const notOwnedOutputs = React.useMemo(() => tx.outputs.filter((output) => !output.ownAddress), [tx.outputs]) const ownedOutputs = React.useMemo(() => tx.outputs.filter((output) => output.ownAddress), [tx.outputs]) - const componentsDuplicated = operations.components.find((component) => component.duplicated) + const operationsComponentsDuplicated = React.useMemo( + () => operations.components.find((component) => component.duplicated), + [operations.components], + ) return ( - {componentsDuplicated && ( + {operationsComponentsDuplicated && ( <> @@ -157,7 +160,7 @@ const MyWalletSection = ({ operationsFee: Balance.Quantity }) => { const strings = useStrings() - const {styles} = useStyles() + const {styles, colors} = useStyles() const address = ownedOutputs[0]?.rewardAddress ?? ownedOutputs[0]?.address ?? '-' return ( @@ -169,7 +172,7 @@ const MyWalletSection = ({ {address} - {ownedOutputs[0]?.addressKind === CredKind.Script && } + {ownedOutputs[0]?.addressKind === CredKind.Script && } @@ -249,7 +252,7 @@ const OneExternalPartySection = ({ receiverCustomTitle?: React.ReactNode }) => { const address = output?.rewardAddress ?? output?.address ?? '-' - const {styles} = useStyles() + const {styles, colors} = useStyles() const strings = useStrings() return ( @@ -274,7 +277,7 @@ const OneExternalPartySection = ({ {address} - {output?.addressKind === CredKind.Script && } + {output?.addressKind === CredKind.Script && } )} @@ -283,7 +286,7 @@ const OneExternalPartySection = ({ } const MultiExternalPartiesSection = ({outputs}: {outputs: FormattedOutputs}) => { - const {styles} = useStyles() + const {styles, colors} = useStyles() const {wallet} = useSelectedWallet() const strings = useStrings() @@ -302,7 +305,7 @@ const MultiExternalPartiesSection = ({outputs}: {outputs: FormattedOutputs}) => {address} - {output?.addressKind === CredKind.Script && } + {output?.addressKind === CredKind.Script && } @@ -574,6 +577,7 @@ const useStyles = () => { const colors = { send: color.primary_500, received: color.green_static, + icon: color.el_gray_medium, } return {styles, colors} as const diff --git a/apps/wallet-mobile/translations/messages/src/AppNavigator.json b/apps/wallet-mobile/translations/messages/src/AppNavigator.json index 404a3761bb..446e819fb5 100644 --- a/apps/wallet-mobile/translations/messages/src/AppNavigator.json +++ b/apps/wallet-mobile/translations/messages/src/AppNavigator.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Enter PIN", "file": "src/AppNavigator.tsx", "start": { - "line": 254, + "line": 251, "column": 17, - "index": 9784 + "index": 9472 }, "end": { - "line": 257, + "line": 254, "column": 3, - "index": 9874 + "index": 9562 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!Set PIN", "file": "src/AppNavigator.tsx", "start": { - "line": 258, + "line": 255, "column": 18, - "index": 9894 + "index": 9582 }, "end": { - "line": 261, + "line": 258, "column": 3, - "index": 9992 + "index": 9680 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Auth with OS changes", "file": "src/AppNavigator.tsx", "start": { - "line": 262, + "line": 259, "column": 25, - "index": 10019 + "index": 9707 }, "end": { - "line": 265, + "line": 262, "column": 3, - "index": 10133 + "index": 9821 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Auth with OS changed detected", "file": "src/AppNavigator.tsx", "start": { - "line": 266, + "line": 263, "column": 27, - "index": 10162 + "index": 9850 }, "end": { - "line": 269, + "line": 266, "column": 3, - "index": 10283 + "index": 9971 } } ] \ No newline at end of file