Skip to content

Commit

Permalink
Merge pull request #24 from multiversx/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
radumojic authored Nov 6, 2023
2 parents 2d35a58 + 6773751 commit 8969fa2
Show file tree
Hide file tree
Showing 39 changed files with 299 additions and 333 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# MultiversX Explorer

![explorer.multiversx.com](https://github.com/multiversx/mx-explorer-dapp/blob/main/public/share.jpg)

This project was bootstrapped with [Vite](https://vitejs.dev/guide/).

## Deployments
Expand Down
16 changes: 12 additions & 4 deletions src/components/AccountLink/AccountLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ export const AccountLink = ({
address,
assets,
className,
linkClassName
linkClassName,
'data-testid': testId
}: AccountLinkType) => {
return (
<div
className={classNames('d-flex', 'align-items-center', className, {
hash: !className
})}
className={classNames(
'd-flex',
'align-items-center',
'trim-wrapper',
className,
{
hash: !className
}
)}
data-testid={testId}
>
<ScAddressIcon initiator={address} />
{addressIsBech32(address) ? (
Expand Down
7 changes: 6 additions & 1 deletion src/components/NetworkLink/NetworkLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const NetworkLink = ({
to,
children,
preventScrollReset = false,
'data-testid': dataTestId,
...rest
}: NetworkLinkPropsType) => {
const { id: activeNetworkId } = useSelector(activeNetworkSelector);
Expand All @@ -32,7 +33,11 @@ export const NetworkLink = ({
};

return (
<Link {...props} preventScrollReset={preventScrollReset}>
<Link
{...props}
preventScrollReset={preventScrollReset}
{...(dataTestId ? { 'data-testid': dataTestId } : {})}
>
{children}
</Link>
);
Expand Down
31 changes: 7 additions & 24 deletions src/components/ScResultsTable/components/ScResultRow.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
import {
ScAddressIcon,
ShardSpan,
NetworkLink,
TimeAgo,
Trim,
Denominate
Denominate,
AccountLink
} from 'components';
import { addressIsBech32, urlBuilder } from 'helpers';
import { TransactionSCResultType } from 'types';

export interface ScResultRowType {
scResult: TransactionSCResultType;
address?: string;
}

export const ScAccountLink = ({
address,
testId
}: {
address: string;
testId?: string;
}) =>
addressIsBech32(address) ? (
<NetworkLink
to={urlBuilder.accountDetails(address)}
data-testid={testId ? testId : 'addressLink'}
className='trim-wrapper'
>
<Trim text={address} />
</NetworkLink>
) : (
<ShardSpan shard={address} />
);

export const ScResultRow = ({ scResult, address }: ScResultRowType) => {
const directionOut = address === scResult.sender;
const directionIn = address === scResult.receiver;
Expand Down Expand Up @@ -65,7 +45,7 @@ export const ScResultRow = ({ scResult, address }: ScResultRowType) => {
{directionOut ? (
<Trim text={scResult.sender} />
) : (
<ScAccountLink address={scResult.sender} testId='senderLink' />
<AccountLink address={scResult.sender} data-testid='senderLink' />
)}
</div>
</td>
Expand All @@ -75,7 +55,10 @@ export const ScResultRow = ({ scResult, address }: ScResultRowType) => {
{directionIn ? (
<Trim text={scResult.receiver} />
) : (
<ScAccountLink address={scResult.receiver} testId='receiverLink' />
<AccountLink
address={scResult.receiver}
data-testid='receiverLink'
/>
)}
</div>
</td>
Expand Down
14 changes: 11 additions & 3 deletions src/components/TimeAgo/TimeAgo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { timeAgo } from './helpers/timeAgo';
export const TimeAgo = ({
value,
short = false,
tooltip = false
tooltip = false,
showAgo = false
}: {
value: number;
short?: boolean;
tooltip?: boolean;
showAgo?: boolean;
}) => {
const ms = value * 1000;
let result = timeAgo(ms);
Expand All @@ -31,9 +33,15 @@ export const TimeAgo = ({
</Tooltip>
)}
>
<span>{result}</span>
<span>
{result}
{showAgo ? ' ago' : ''}
</span>
</OverlayTrigger>
) : (
<>{result}</>
<>
{result}
{showAgo ? ' ago' : ''}
</>
);
};
10 changes: 4 additions & 6 deletions src/components/TimeAgo/helpers/timeAgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export function dhms(ms: number) {
const minsms = hrsms % (60 * 1000);
const secs = Math.floor(minsms / 1000);

// let diff = ' ago';
const diff = '';
let secsString = secs + ' sec';
let minsString = mins + ' min';
let hrsString = hrs + ' hr';
Expand All @@ -21,17 +19,17 @@ export function dhms(ms: number) {
if (hrs > 1) hrsString = hrs + ' hrs';
if (days > 1) daysString = days + ' days';

if (days >= 1) return daysString + ' ' + hrsString + diff;
if (days >= 1) return daysString + ' ' + hrsString;
if (hrs >= 1) {
const minutesString = mins === 0 ? '' : ' ' + minsString + diff;
const minutesString = mins === 0 ? '' : ' ' + minsString;
return hrsString + minutesString;
}
if (mins >= 1) {
const secString = secs === 0 ? '' : ' ' + secsString + diff;
const secString = secs === 0 ? '' : ' ' + secsString;
return minsString + secString;
}

return secsString + diff;
return secsString;
}

export const timeAgo = (timestamp: number) => {
Expand Down
18 changes: 6 additions & 12 deletions src/components/TransactionAction/TransactionAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { useSelector } from 'react-redux';

import { ReactComponent as DefaultAvatar } from 'assets/img/default-avatar.svg';
import {
ScAddressIcon,
NetworkLink,
AccountName,
AccountLink,
Denominate,
TransactionActionBlock,
NftBadge
Expand Down Expand Up @@ -110,16 +109,11 @@ const ActionText = ({
}

return addressIsBech32(entry.address) ? (
<div className='d-flex align-items-center'>
<ScAddressIcon initiator={entry.address} />
<NetworkLink
to={urlBuilder.accountDetails(entry.address)}
data-testid='receiverLink'
className='trim-wrapper'
>
<AccountName address={entry.address} assets={entryAssets} />
</NetworkLink>
</div>
<AccountLink
address={entry.address}
assets={entryAssets}
data-testid='receiverLink'
/>
) : (
''
);
Expand Down
50 changes: 22 additions & 28 deletions src/components/TransactionsTable/components/TransactionRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
AccountLink,
ScAddressIcon,
ShardSpan,
NetworkLink,
Expand All @@ -9,7 +10,7 @@ import {
AccountName,
TransactionIcon
} from 'components';
import { addressIsBech32, urlBuilder, getDisplayReceiver } from 'helpers';
import { urlBuilder, getDisplayReceiver } from 'helpers';
import { faArrowRight } from 'icons/regular';
import { UITransactionType, TransferTypeEnum } from 'types';

Expand Down Expand Up @@ -99,29 +100,21 @@ export const TransactionRow = ({
{showLockedAccounts && (
<LockedTokenAddressIcon address={transaction.sender} />
)}
<ScAddressIcon initiator={transaction.sender} />

{directionOut ? (
<AccountName
<>
<ScAddressIcon initiator={transaction.sender} />
<AccountName
address={transaction.sender}
assets={transaction.senderAssets}
/>
</>
) : (
<AccountLink
address={transaction.sender}
assets={transaction.senderAssets}
data-testid='senderLink'
/>
) : (
<>
{addressIsBech32(transaction.sender) ? (
<NetworkLink
to={urlBuilder.accountDetails(transaction.sender)}
data-testid='senderLink'
className='trim-wrapper'
>
<AccountName
address={transaction.sender}
assets={transaction.senderAssets}
/>
</NetworkLink>
) : (
<ShardSpan shard={transaction.sender} />
)}
</>
)}
</div>
</td>
Expand All @@ -140,17 +133,18 @@ export const TransactionRow = ({
<td>
<div className='d-flex align-items-center receiver'>
{showLockedAccounts && <LockedTokenAddressIcon address={receiver} />}
<ScAddressIcon initiator={receiver} />

{directionIn ? (
<AccountName address={receiver} assets={receiverAssets} />
<>
<ScAddressIcon initiator={receiver} />
<AccountName address={receiver} assets={receiverAssets} />
</>
) : (
<NetworkLink
to={urlBuilder.accountDetails(receiver)}
<AccountLink
address={receiver}
assets={receiverAssets}
data-testid='receiverLink'
className='trim-wrapper'
>
<AccountName address={receiver} assets={receiverAssets} />
</NetworkLink>
/>
)}
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ const MultipleTokensBadge = ({
);

return (
<Overlay title={<Tooltip />}>
<FontAwesomeIcon
icon={faLayerPlus}
className='ms-2 text-neutral-400 cursor-context'
/>
<Overlay title={<Tooltip />} className='cursor-context multiple-tokens'>
<FontAwesomeIcon icon={faLayerPlus} className='ms-1 text-neutral-400' />
</Overlay>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
.transaction-value {
color: var(--body-color);
max-width: 13.5rem;
min-width: 13.5rem;
max-width: 12.5rem;
min-width: 12.5rem;
}
.transaction-function {
max-width: 9.5rem;
Expand Down
1 change: 1 addition & 0 deletions src/components/Trim/trim.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ a:hover > .trim span {
}
}
.table .trim-size-xl .trim {
max-width: 10rem;
@include media-breakpoint-up(md) {
max-width: 13rem;
}
Expand Down
10 changes: 7 additions & 3 deletions src/hooks/adapter/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function getTransactionsParams({
miniBlockHash,
search,
token,
order,
withUsername = true
}: GetTransactionsType) {
const params: AdapterProviderPropsType['params'] = {
Expand All @@ -50,7 +51,8 @@ export function getTransactionsParams({
...(status ? { status } : {}),
...(miniBlockHash ? { miniBlockHash } : {}),
...(search ? { search } : {}),
...(token ? { token } : {})
...(token ? { token } : {}),
...(order ? { order } : {})
};

return params;
Expand Down Expand Up @@ -136,7 +138,8 @@ export function getCollectionsParams({
identifiers,
type,
sort,
excludeMetaESDT
excludeMetaESDT,
withOwner
}: GetCollectionsType) {
const params: AdapterProviderPropsType['params'] = {
...(fields !== undefined ? { fields } : {}),
Expand All @@ -146,7 +149,8 @@ export function getCollectionsParams({
...(sort !== undefined ? { sort } : {}),
...(excludeMetaESDT !== undefined ? { excludeMetaESDT } : {}),
...(page !== undefined ? { from: (page - 1) * size } : {}),
...(size !== undefined ? { size } : {})
...(size !== undefined ? { size } : {}),
...(withOwner !== undefined ? { withOwner } : {})
};

return params;
Expand Down
Loading

0 comments on commit 8969fa2

Please sign in to comment.