Skip to content

Commit

Permalink
fix(suite-native): send review old flow outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
PeKne committed Oct 2, 2024
1 parent f011e21 commit c068bbe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
19 changes: 12 additions & 7 deletions suite-native/module-send/src/components/ReviewOutputItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,33 @@ type ReviewOutputItemProps = {
reviewOutput: StatefulReviewOutput;
onLayout: (event: LayoutChangeEvent) => void;
};
type SupportedOutputType = Extract<ReviewOutputType, 'amount' | 'address'>;

const outputLabelTranslationMap = {
address: 'moduleSend.review.outputs.addressLabel',
regular_legacy: 'moduleSend.review.outputs.addressLabel',
amount: 'moduleSend.review.outputs.amountLabel',
} as const satisfies Record<SupportedOutputType, TxKeyPath>;
} as const satisfies Partial<Record<ReviewOutputType, TxKeyPath>>;

const isTranslationDefined = (
type: ReviewOutputType,
): type is keyof typeof outputLabelTranslationMap => {
return type in outputLabelTranslationMap;
};

export const ReviewOutputItem = ({
reviewOutput,
networkSymbol,
onLayout,
}: ReviewOutputItemProps) => {
const { state, type, value } = reviewOutput;
const { translate } = useTranslate();

const { state, type, value } = reviewOutput;
const titleTxKey = isTranslationDefined(type) ? outputLabelTranslationMap[type] : null;
const title = titleTxKey ? translate(titleTxKey) : type;

return (
<View onLayout={onLayout}>
<ReviewOutputCard
title={translate(outputLabelTranslationMap[type as SupportedOutputType])}
outputState={state}
>
<ReviewOutputCard title={title} outputState={state}>
<ReviewOutputItemContent
outputType={type}
networkSymbol={networkSymbol}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const ReviewOutputItemContent = ({
);
}

if (outputType === 'address') {
if (outputType === 'address' || outputType === 'regular_legacy') {
const chunkedAddress = splitAddressToChunks(value).join(' ');

return <Text variant="hint">{chunkedAddress}</Text>;
Expand Down
7 changes: 6 additions & 1 deletion suite-native/module-send/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@suite-common/wallet-core';
import {
constructTransactionReviewOutputs,
getIsUpdatedSendFlow,
getTransactionReviewOutputState,
isRbfTransaction,
} from '@suite-common/wallet-utils';
Expand Down Expand Up @@ -50,7 +51,11 @@ export const selectTransactionReviewOutputs = (
precomposedTx,
});

return outputs?.map(
const newFlowOutputs = getIsUpdatedSendFlow(device)
? outputs
: outputs?.filter(output => output.type !== 'fee'); // The `fee` output is already included in the final transaction summary output.

return newFlowOutputs.map(
(output, outputIndex) =>
({
...output,
Expand Down

0 comments on commit c068bbe

Please sign in to comment.