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 Oct 23, 2024
2 parents 306d402 + e50dafa commit b925cdd
Show file tree
Hide file tree
Showing 168 changed files with 3,103 additions and 2,368 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"@types/ua-parser-js": "0.7.39",
"@typescript-eslint/eslint-plugin": "5.61.0",
"@typescript-eslint/parser": "5.61.0",
"@vitejs/plugin-basic-ssl": "1.1.0",
"@vitejs/plugin-react-swc": "3.3.2",
"cross-env": "7.0.3",
"cypress": "13.1.0",
Expand All @@ -116,8 +117,7 @@
"run-script-os": "1.1.6",
"sass": "1.62.1",
"typescript": "5.1.6",
"vite": "4.4.12",
"vite-plugin-mkcert": "1.16.0",
"vite": "4.5.0",
"vite-plugin-node-polyfills": "0.9.0",
"vite-plugin-svgr": "3.2.0",
"vite-tsconfig-paths": "4.2.0"
Expand Down
5 changes: 4 additions & 1 deletion src/appConstants/apiFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export const TRANSACTIONS_TABLE_FIELDS = [
'tokenIdentifier',
'function',
'action',
'guardianSignature'
'type',
'guardianSignature',
'isRelayed',
'relayedVersion'
];

export const IDENTITIES_FIELDS = [
Expand Down
3 changes: 2 additions & 1 deletion src/appConstants/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './apiFields';

export const BRAND_NAME = process.env.VITE_APP_BRAND_NAME ?? 'MultiversX';
export const BRAND_NAME = import.meta.env.VITE_APP_BRAND_NAME ?? 'MultiversX';

export const METACHAIN_SHARD_ID = 4294967295;
export const MAIN_SHARD_ID = 4294967293;
Expand All @@ -24,6 +24,7 @@ export const AUCTION_LIST_MAX_NODES = 3000;
export const AUCTION_LIST_QUALIFIED_MIN_DISPLAY_ROW_COUNT = 10;
export const AUCTION_LIST_MIN_DISPLAY_ROW_COUNT = 6;

export const NATIVE_TOKEN_IDENTIFIER = 'EGLD-000000';
export const LEGACY_DELEGATION_NODES_IDENTITY = 'multiversx';
export const HEROTAG_SUFFIX = '.elrond';
export const TEMP_LOCAL_NOTIFICATION_DISMISSED = 'tempNotificationDismissed2';
Expand Down
2 changes: 1 addition & 1 deletion src/assets/scss/components/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
@import '../../../components/Marquee/marquee.styles.scss';
@import '../../../components/MultilayerPercentage/multilayerPercentage.styles.scss';
@import '../../../components/NftPreview/nftPreview.styles.scss';
@import '../../../components/NodesTable/nodesTable.styles.scss';
@import '../../../components/Nodes/AuctionListTable/auctionListTables.styles.scss';
@import '../../../components/Nodes/NodesOverview/nodesOverview.styles.scss';
@import '../../../components/Nodes/NodesStatusPreviewCards/nodesStatusPreviewCards.styles.scss';
@import '../../../components/NodesTable/nodesTable.styles.scss';
@import '../../../components/NotificationsBar/notificationsBar.styles.scss';
@import '../../../components/Pager/pager.styles.scss';
@import '../../../components/PageState/components/IconState/iconState.styles.scss';
Expand Down
4 changes: 3 additions & 1 deletion src/assets/scss/components/_pages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
@import '../../../pages/AccountDetails/AccountTokensTable/accountTokensTable.styles.scss';
@import '../../../pages/Analytics/analytics.styles.scss';
@import '../../../pages/BlockDetails/blockDetails.styles.scss';
@import '../../../pages/Home/home.styles.scss';
@import '../../../pages/Identities/identities.styles.scss';
@import '../../../pages/NativeToken/nativeToken.styles.scss';
@import '../../../pages/NftDetails/nftDetails.styles.scss';
@import '../../../pages/NodeDetails/components/NetworkMetrics/networkMetrics.styles.scss';
@import '../../../pages/NodeDetails/components/Rounds/rounds.styles.scss';
@import '../../../pages/NodesAuctionList/nodesAuctionList.styles.scss';
@import '../../../pages/Tokens/components/TokensTable/tokensTable.styles.scss';
@import '../../../pages/TransactionDetails/components/TransactionInfo/DataField/dataField.styles.scss';
@import '../../../pages/TransactionDetails/components/DataField/dataField.styles.scss';
@import '../../../pages/TransactionDetails/components/TransactionInfo/transactionInfo.styles.scss';
8 changes: 4 additions & 4 deletions src/assets/scss/components/_widgets.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import '../../../widgets/ChartCard/chartCard.styles.scss';
@import '../../../widgets/ChartContractsTransactions/chartContractsTransactions.styles.scss';
@import '../../../widgets/EconomicsCard/economicsCard.styles.scss';
@import '../../../widgets/HeroHome/heroHome.styles.scss';
@import '../../../widgets/HeroNodes/heroNodes.styles.scss';
@import '../../../widgets/HeroPills/heroPills.styles.scss';
@import '../../../widgets/MostUsed/mostUsed.styles.scss';
@import '../../../widgets/ValidatorsStatusCard/validatorsStatusCard.styles.scss';
@import '../../../widgets/StatsCard/statsCard.styles.scss';

// temp
@import '../../../pages/Home/components/ChartContractsTransactions/chartContractsTransactions.styles.scss';
@import '../../../widgets/ValidatorsStatusCard/validatorsStatusCard.styles.scss';
3 changes: 2 additions & 1 deletion src/assets/scss/elements/_badges.scss
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ button.badge {
@extend .badge-outline-grey;
}
&.internal,
&.int {
&.int,
&.inner-tx {
@extend .badge-outline-grey;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/assets/scss/elements/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
border-radius: 0.5rem;
background-color: transparent;

@media (min-width: 768px) {
@include media-breakpoint-up(md) {
font-size: 1rem;
padding: 0.75rem 1rem;
}
Expand All @@ -45,7 +45,7 @@
&.active {
color: var(--primary);
}
@media (min-width: 768px) {
@include media-breakpoint-up(md) {
font-size: 1.5rem;
padding: 0.5rem 0.75rem;
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/scss/plugins/_sdk-dapp-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ a .dapp-core-component__trim-styles__ellipsis {
}
}

@media (min-width: 768px) {
@include media-breakpoint-up(md) {
.dapp-core-component__signWithDeviceModalStyles__modal-layout-content.dapp-core-component__signWithDeviceModalStyles__spaced {
padding: 2rem 0.75rem 1.5rem 0.75rem !important;
}
Expand Down
170 changes: 170 additions & 0 deletions src/components/AccountsTable/AccountsTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import BigNumber from 'bignumber.js';
import classNames from 'classnames';

import {
FormatAmount,
AccountLink,
FormatNumber,
FormatUSD,
PercentageBar,
Pager,
PageSize,
Loader,
PageState
} from 'components';
import { DECIMALS } from 'config';
import { formatBigNumber, parseAmount } from 'helpers';
import { faUser } from 'icons/regular';
import { AccountType, TokenLockedAccountType, WithClassnameType } from 'types';

export interface AccountsTableUIType extends WithClassnameType {
accounts: AccountType[] | TokenLockedAccountType[];
accountsCount: number;
title?: React.ReactNode;
message?: string;
decimals?: number;
showValue?: boolean;
supply?: string | number;
price?: number;
isDataReady?: boolean;
hasNameColumn?: boolean;
isNativeToken?: boolean;
}

export const AccountsTable = ({
accounts,
accountsCount,
title,
message = 'Accounts',
decimals = DECIMALS,
showValue,
price,
supply,
isNativeToken = false,
isDataReady,
hasNameColumn
}: AccountsTableUIType) => {
const hasSupply = new BigNumber(supply ?? 0).isGreaterThan(0);
const showAccounts = isDataReady === true && accounts.length > 0;

return (
<div className='card'>
<div className='card-header'>
<div className='card-header-item table-card-header d-flex justify-content-between align-items-center flex-wrap gap-3'>
{title}
<Pager
total={accountsCount}
show={accounts.length > 0}
className='d-flex ms-auto me-auto me-sm-0'
/>
</div>
</div>
{showAccounts ? (
<>
<div className='card-body'>
<div className='table-wrapper animated-list'>
<table className='table mb-0'>
<thead>
<tr>
<th className={classNames({ 'w-50': !price })}>Address</th>
{hasNameColumn && <th>Name</th>}
<th>Balance</th>
{hasSupply && (
<th className='percentage-column'>Percentage</th>
)}
{showValue && <th className='value-column'>Value</th>}
</tr>
</thead>
<tbody data-testid='accountsTable'>
{accounts.map((account) => {
const holdingsPercentage =
hasSupply && supply
? new BigNumber(account.balance)
.times(100)
.dividedBy(parseAmount(supply, decimals))
: new BigNumber(0);
const hasAccountName =
hasNameColumn && (account as TokenLockedAccountType).name;

return (
<tr key={account.address}>
<td>
<div className='d-flex align-items-center gap-2'>
<AccountLink
address={account.address}
assets={account.assets}
className={price ? 'hash hash-xl' : 'full-hash'}
linkClassName={price ? '' : 'trim-only-sm'}
/>
</div>
</td>
{hasAccountName && (
<td>{(account as TokenLockedAccountType).name}</td>
)}
<td>
<FormatAmount
value={account.balance}
decimals={decimals}
showLastNonZeroDecimal={true}
showLabel={isNativeToken}
showSymbol={isNativeToken}
showUsdValue={false}
/>
</td>
{hasSupply && (
<td>
<div className='mb-1'>
<FormatNumber
value={holdingsPercentage}
label='%'
/>
</div>
<PercentageBar
overallPercent={0}
fillPercent={holdingsPercentage.toNumber()}
fillPercentLabel={`${formatBigNumber({
value: holdingsPercentage
})}%`}
type='small'
/>
</td>
)}
{showValue && (
<td>
<FormatUSD
value={account.balance}
decimals={decimals}
usd={price}
/>
</td>
)}
</tr>
);
})}
</tbody>
</table>
</div>
</div>
<div className='card-footer table-footer'>
<PageSize />
<Pager total={accountsCount} show={accounts.length > 0} />
</div>
</>
) : (
<>
{isDataReady === undefined && <Loader data-testid='accountsLoader' />}
{isDataReady === false && (
<PageState
icon={faUser}
title={`Unable to load ${message}`}
isError
/>
)}
{isDataReady === true && accounts.length === 0 && (
<PageState icon={faUser} title={`No ${message}`} />
)}
</>
)}
</div>
);
};
1 change: 1 addition & 0 deletions src/components/AccountsTable/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './AccountsTable';
13 changes: 11 additions & 2 deletions src/components/DataDecode/DataDecode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ const treatSmartDecodingCases = ({
const updatedParts = [...decodedParts];

if (parts[0] === 'ESDTNFTTransfer' && parts[2]) {
updatedParts[2] = decode(parts[2], 'decimal');
updatedParts[2] = decode(parts[2], DecodeMethodEnum.decimal);
}
if (identifier === 'ESDTNFTTransfer' && parts[1]) {
const base64Buffer = Buffer.from(String(parts[1]), 'base64');
updatedParts[1] = decode(base64Buffer.toString('hex'), 'decimal');
updatedParts[1] = decode(
base64Buffer.toString('hex'),
DecodeMethodEnum.decimal
);
}

return updatedParts;
Expand Down Expand Up @@ -237,6 +240,12 @@ export const DataDecode = ({
}
}, [activeKey]);

useEffect(() => {
if (defaultDecodeMethod !== activeKey) {
setActiveKey(defaultDecodeMethod);
}
}, [defaultDecodeMethod]);

return (
<div
className={`position-relative data-decode mt-1 ${
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorElement/ErrorElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { faTimes } from 'icons/regular';

export const ErrorElement = () => {
const { pathname } = useLocation();
const explorerVersion = process.env.VITE_APP_CACHE_BUST;
const explorerVersion = import.meta.env.VITE_APP_CACHE_BUST;
const error = useRouteError();
console.error(error);

Expand Down
4 changes: 2 additions & 2 deletions src/components/Filters/SelectFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export const SelectFilter = ({
if (hasCustomSearch && existingValues.length > 0) {
const searchedOptions = existingValues.map((value) => {
return {
value: value,
value,
label: capitalize(value)
};
});

searchedOptions.forEach((value) => {
if (options.some((option) => option.label !== value.label)) {
if (options.every((option) => option.value !== value.value)) {
options.push(value);
}
});
Expand Down
Loading

0 comments on commit b925cdd

Please sign in to comment.