Skip to content

Commit

Permalink
updated anchored display
Browse files Browse the repository at this point in the history
  • Loading branch information
radumojic committed Dec 6, 2024
1 parent afe8190 commit 2534783
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
23 changes: 13 additions & 10 deletions src/components/DataDecode/DataDecode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ import { Anchor, Dropdown } from 'react-bootstrap';
import { MAX_DECODE_TX_DATA_LENGTH } from 'appConstants';
import { CopyButton } from 'components';
import { faExclamationTriangle } from 'icons/regular';
import { WithClassnameType } from 'types';

export interface DataDecodeUIType extends WithClassnameType {
value: string;
className?: string;
initialDecodeMethod?: DecodeMethodEnum;
setDecodeMethod?: Dispatch<SetStateAction<DecodeMethodEnum>>;
identifier?: string;
anchoredContent?: ReactNode;
}

export const DataDecode = ({
value,
className,
initialDecodeMethod,
setDecodeMethod,
identifier,
children
}: {
value: string;
className?: string;
initialDecodeMethod?: DecodeMethodEnum;
setDecodeMethod?: Dispatch<SetStateAction<DecodeMethodEnum>>;
identifier?: string;
children?: ReactNode;
}) => {
anchoredContent
}: DataDecodeUIType) => {
const defaultDecodeMethod =
initialDecodeMethod &&
Object.values<string>(DecodeMethodEnum).includes(initialDecodeMethod)
Expand Down Expand Up @@ -76,7 +79,7 @@ export const DataDecode = ({
}`}
>
<div className={`form-control textarea ${className ? className : ''}`}>
{children ? children : displayValue}
{anchoredContent ? anchoredContent : displayValue}
</div>
{value && value !== 'N/A' && (
<div className='d-flex button-holder'>
Expand Down
30 changes: 18 additions & 12 deletions src/pages/TransactionDetails/components/DataField/DataField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export const DataField = ({
}, [decodeMethod, pathname]);

const showRawLinks =
decodeMethod === DecodeMethodEnum.raw && (showData || skipDataScamCheck);
decodeMethod === DecodeMethodEnum.raw &&
stringWithLinks &&
(showData || skipDataScamCheck);

const value = truncate(
skipDataScamCheck ? dataString : output,
MAX_DISPLAY_TX_DATA_LENGTH
Expand All @@ -76,17 +79,20 @@ export const DataField = ({
value={value}
initialDecodeMethod={!id ? dataDecode : DecodeMethodEnum.raw}
setDecodeMethod={setDecodeMethod}
>
{showRawLinks && (
<Anchorme
linkComponent={ModalLink}
target='_blank'
rel='noreferrer nofollow noopener'
>
{stringWithLinks}
</Anchorme>
)}
</DataDecode>
{...(showRawLinks
? {
anchoredContent: (
<Anchorme
linkComponent={ModalLink}
target='_blank'
rel='noreferrer nofollow noopener'
>
{stringWithLinks || output}
</Anchorme>
)
}
: {})}
/>
{found && !skipDataScamCheck && (
<a href='/#' onClick={show} className='small-font text-muted'>
{!showData ? 'Show' : 'Hide'} original message
Expand Down

0 comments on commit 2534783

Please sign in to comment.