Skip to content

Commit

Permalink
fix(suite): display black-box for opreturn and data for Ethereum, als…
Browse files Browse the repository at this point in the history
…o fix the order (data are first to confirm on Ethereum)
  • Loading branch information
peter-sanderson committed May 7, 2024
1 parent 39ad328 commit c6d791c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ConfirmAddressModal = ({ addressPath, value, ...props }: ConfirmAdd
const receiveSymbol = useSelector(
state => state.wallet.coinmarket.exchange.quotesRequest?.receive,
);
const displayMode = useDisplayMode();
const displayMode = useDisplayMode({ type: 'address' });

const validateAddress = useCallback(
() => showAddress(addressPath, value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const TransactionReviewOutput = forwardRef<HTMLDivElement, TransactionRev
let outputLabel: ReactNode = label;
const { networkType } = account;
const { translationString } = useTranslation();
const displayMode = useDisplayMode(ethereumStakeType);
const displayMode = useDisplayMode({ ethereumStakeType, type });

if (type === 'locktime') {
const isTimestamp = new BigNumber(value).gte(BTC_LOCKTIME_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { zIndices } from '@trezor/theme';
import { DeviceDisplay } from '../../../../DeviceDisplay/DeviceDisplay';
import { DisplayMode } from 'src/types/suite';

const TYPES_TO_BE_DISPLAYED_IN_SCREEN_BOX = ['address', 'regular_legacy', 'data', 'opreturn'];

const OutputWrapper = styled.div`
display: flex;
margin-top: 32px;
Expand Down Expand Up @@ -192,7 +194,7 @@ export const TransactionReviewOutputElement = forwardRef<
<OutputValue>
{isActive &&
displayMode &&
(line.id === 'address' || line.id === 'regular_legacy') ? (
TYPES_TO_BE_DISPLAYED_IN_SCREEN_BOX.includes(line.id) ? (
<DeviceDisplay displayMode={displayMode} address={line.value} />
) : (
<OutputValueWrapper>
Expand Down
11 changes: 9 additions & 2 deletions packages/suite/src/hooks/suite/useDisplayMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import { selectSelectedAccount } from 'src/reducers/wallet/selectedAccountReduce
import { useSelector } from './useSelector';
import { StakeType } from '@suite-common/wallet-types';
import { DisplayMode } from 'src/types/suite';
import { ReviewOutput } from '../../types/wallet/transaction';

export const useDisplayMode = (ethereumStakeType?: StakeType) => {
type UseDisplayModeProps = {
type: ReviewOutput['type'];
ethereumStakeType?: StakeType;
};

export const useDisplayMode = ({ type, ethereumStakeType }: UseDisplayModeProps) => {
const account = useSelector(selectSelectedAccount);
const unavailableCapabilities = useSelector(selectDeviceUnavailableCapabilities);
const addressDisplayType = useSelector(selectAddressDisplayType);

if (ethereumStakeType) {
if (ethereumStakeType || ['data', 'opreturn'].includes(type)) {
return DisplayMode.SINGLE_WRAPPED_TEXT;
}

if (
addressDisplayType === AddressDisplayOptions.CHUNKED &&
!unavailableCapabilities?.chunkify &&
Expand Down
10 changes: 5 additions & 5 deletions packages/suite/src/utils/wallet/reviewTransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ const constructNewFlow = ({
const hasBitcoinLockTime = 'bitcoinLockTime' in precomposedForm;
const hasRippleDestinationTag = 'rippleDestinationTag' in precomposedForm;

// used in the bumb fee flow
if (precomposedForm.ethereumDataHex && !precomposedTx.token) {
outputs.push({ type: 'data', value: precomposedForm.ethereumDataHex });
}

// used in the bump fee flow
if (typeof precomposedTx.useNativeRbf === 'boolean' && precomposedTx.useNativeRbf) {
outputs.push(
{
Expand Down Expand Up @@ -293,10 +297,6 @@ const constructNewFlow = ({
outputs.push({ type: 'locktime', value: precomposedForm.bitcoinLockTime });
}

if (precomposedForm.ethereumDataHex && !precomposedTx.token) {
outputs.push({ type: 'data', value: precomposedForm.ethereumDataHex });
}

if (
networkType === 'ripple' &&
hasRippleDestinationTag &&
Expand Down

0 comments on commit c6d791c

Please sign in to comment.