Skip to content

Commit

Permalink
Merge branch 'development' of github.com:multiversx/mx-explorer-dapp …
Browse files Browse the repository at this point in the history
…into next
  • Loading branch information
radumojic committed Nov 15, 2024
2 parents a5b0bda + 47efb49 commit 5bb647f
Show file tree
Hide file tree
Showing 5 changed files with 577 additions and 700 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"@fortawesome/free-regular-svg-icons": "6.5.1",
"@fortawesome/free-solid-svg-icons": "6.5.1",
"@fortawesome/react-fontawesome": "0.2.0",
"@multiversx/sdk-dapp": "2.40.0",
"@multiversx/sdk-dapp-sc-explorer": "0.0.1-beta.9",
"@multiversx/sdk-core": "13.15.0",
"@multiversx/sdk-dapp": "3.0.10",
"@multiversx/sdk-dapp-sc-explorer": "0.0.2-beta.0",
"@react-three/fiber": "8.17.6",
"@reduxjs/toolkit": "1.9.5",
"anchorme": "2.1.2",
"axios": "1.7.5",
"axios": "1.7.4",
"bech32": "2.0.0",
"bignumber.js": "9.1.2",
"bootstrap": "5.2.3",
Expand Down
14 changes: 11 additions & 3 deletions src/components/DataDecode/DataDecode.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
import {
Dispatch,
ReactNode,
SetStateAction,
useEffect,
useState
} from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import BigNumber from 'bignumber.js';
import { Anchor, Dropdown } from 'react-bootstrap';
Expand Down Expand Up @@ -197,13 +203,15 @@ export const DataDecode = ({
className,
initialDecodeMethod,
setDecodeMethod,
identifier
identifier,
children
}: {
value: string;
className?: string;
initialDecodeMethod?: DecodeMethodEnum;
setDecodeMethod?: Dispatch<SetStateAction<DecodeMethodEnum>>;
identifier?: string;
children?: ReactNode;
}) => {
const defaultDecodeMethod =
initialDecodeMethod &&
Expand Down Expand Up @@ -253,7 +261,7 @@ export const DataDecode = ({
}`}
>
<div className={`form-control textarea ${className ? className : ''}`}>
{displayValue}
{children ? children : displayValue}
</div>
{value && value !== 'N/A' && (
<div className='d-flex button-holder'>
Expand Down
43 changes: 26 additions & 17 deletions src/pages/TransactionDetails/components/DataField/DataField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ import {
useGetTransactionUrlHashParams
} from 'hooks';
import { transactionsRoutes } from 'routes';
import { ScamInfoType } from 'types';
import { ScamInfoType, WithClassnameType } from 'types';

export const DataField = ({
data,
scamInfo
}: {
export interface DataFieldUIType extends WithClassnameType {
data?: string;
scamInfo?: ScamInfoType;
}) => {
skipDataScamCheck?: boolean;
}

export const DataField = ({
data,
scamInfo,
skipDataScamCheck
}: DataFieldUIType) => {
const navigate = useNavigate();
const networkRoute = useNetworkRoute();
const activeRoute = useActiveRoute();
Expand Down Expand Up @@ -59,26 +63,31 @@ export const DataField = ({
}
}, [decodeMethod, pathname]);

const showRawLinks =
decodeMethod === DecodeMethodEnum.raw && (showData || skipDataScamCheck);
const value = truncate(
skipDataScamCheck ? dataString : output,
MAX_DISPLAY_TX_DATA_LENGTH
);

return (
<DetailItem title='Input Data' className='data-field'>
{showData ? (
<div className='textarea form-control col cursor-text mt-1'>
<DataDecode
value={value}
initialDecodeMethod={!id ? dataDecode : DecodeMethodEnum.raw}
setDecodeMethod={setDecodeMethod}
>
{showRawLinks && (
<Anchorme
linkComponent={ModalLink}
target='_blank'
rel='noreferrer nofollow noopener'
>
{stringWithLinks}
</Anchorme>
</div>
) : (
<DataDecode
value={truncate(output, MAX_DISPLAY_TX_DATA_LENGTH)}
initialDecodeMethod={!id ? dataDecode : DecodeMethodEnum.raw}
setDecodeMethod={setDecodeMethod}
/>
)}
{found && (
)}
</DataDecode>
{found && !skipDataScamCheck && (
<a href='/#' onClick={show} className='small-font text-muted'>
{!showData ? 'Show' : 'Hide'} original message
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { activeNetworkSelector } from 'redux/selectors';
import {
TransactionType,
TransactionActionCategoryEnum,
TransactionActionEnum,
TransactionApiStatusEnum
} from 'types';

Expand Down Expand Up @@ -67,6 +68,11 @@ export const TransactionDetailsPanel = ({
const showTotalTxTokenUsdValue =
totalTxTokenUsdValue !== new BigNumber(0).toString();

const skipDataScamCheck =
transaction.sender === receiver &&
transaction.function === TransactionActionEnum.transfer &&
(!transaction.scamInfo || transaction.scamInfo?.type === 'potentialScam');

return (
<>
<DetailItem title='Hash'>
Expand Down Expand Up @@ -324,7 +330,11 @@ export const TransactionDetailsPanel = ({
<TransactionWarningMessage transaction={transaction} />
</DetailItem>

<DataField data={transaction.data} scamInfo={transaction.scamInfo} />
<DataField
data={transaction.data}
scamInfo={transaction.scamInfo}
skipDataScamCheck={skipDataScamCheck}
/>

{transaction.results && transaction.results?.length > 0 && (
<DetailItem
Expand Down
Loading

0 comments on commit 5bb647f

Please sign in to comment.