Skip to content

Commit

Permalink
Merge pull request #111 from multiversx/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
radumojic authored Jul 17, 2024
2 parents b2b02fe + cc64093 commit 45c6649
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 38 deletions.
15 changes: 11 additions & 4 deletions src/helpers/processData/processEconomics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BigNumber from 'bignumber.js';
import { ELLIPSIS } from 'appConstants';
import { DIGITS } from 'config';
import { EconomicsType } from 'types/economics.types';

Expand All @@ -15,14 +16,20 @@ export const processEconomics = (data: EconomicsType) => {
totalSupply: new BigNumber(data.totalSupply).toFormat(0),
circulatingSupply: new BigNumber(data.circulatingSupply).toFormat(0),
staked: new BigNumber(data.staked).toFormat(0),
price: `$${new BigNumber(data.price).toFormat(DIGITS)}`,
marketCap: `$${new BigNumber(data.marketCap).toFormat(0)}`,
price: data.price
? `$${new BigNumber(data.price).toFormat(DIGITS)}`
: ELLIPSIS,
marketCap: data.marketCap
? `$${new BigNumber(data.marketCap).toFormat(0)}`
: ELLIPSIS,
apr: `${new BigNumber(data.apr).times(100).toFormat(DIGITS)}%`,
topUpApr: `${new BigNumber(data.topUpApr).times(100).toFormat(DIGITS)}%`,
baseApr: `${new BigNumber(data.baseApr).times(100).toFormat(DIGITS)}%`,
tokenMarketCap: `$${new BigNumber(data.tokenMarketCap).toFormat(0)}`,
tokenMarketCap: data.tokenMarketCap
? `$${new BigNumber(data.tokenMarketCap).toFormat(0)}`
: ELLIPSIS,

totalStakedPercent: `${totalStakedPercent}%`,
ecosystemMarketCap: `$${ecosystemMarketCap}`
ecosystemMarketCap: ecosystemMarketCap ? `$${ecosystemMarketCap}` : ELLIPSIS
};
};
2 changes: 1 addition & 1 deletion src/hooks/growth/useFetchGrowthMostUsed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useFetchGrowthMostUsed = () => {

const fetchGrowthMostUsed = () => {
if (!isFetched) {
getGrowthWidget('/most-used').then((growthMostUsed) => {
getGrowthWidget('/verified-most-used').then((growthMostUsed) => {
if (growthMostUsed?.data && growthMostUsed.success) {
dispatch(
setGrowthMostUsed({
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export const useSearch = (searchHash: string) => {
networkRoute(urlBuilder.blockDetails(searchHash))
);
break;
case scResult.success && scResult?.data?.originalTxHash:
case Boolean(
scResult.success && scResult?.data?.originalTxHash
):
setSearchRoute(
networkRoute(
urlBuilder.transactionDetails(
Expand Down
22 changes: 10 additions & 12 deletions src/layouts/CollectionLayout/CollectionDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,10 @@ export const CollectionDetailsCard = () => {
}
descriptionContent={
scamInfo ? (
<span className='text-warning d-flex align-items-center ms-2'>
<FontAwesomeIcon
icon={faExclamationTriangle}
size='sm'
className='text-warning me-2'
/>
<div className='d-flex align-items-center flex-wrap gap-2 my-3 text-warning'>
<FontAwesomeIcon icon={faExclamationTriangle} size='sm' />
{scamInfo.info}
</span>
</div>
) : null
}
isVerified={isVerified}
Expand All @@ -93,7 +89,7 @@ export const CollectionDetailsCard = () => {
</Overlay>
}
detailItems={[
assets?.description
assets?.description && !scamInfo
? {
title: 'Description',
value: (
Expand All @@ -106,20 +102,22 @@ export const CollectionDetailsCard = () => {
)
}
: {},
assets?.website
assets?.website && !scamInfo
? {
title: 'Website',
value: <SocialWebsite link={assets.website} />
}
: {},
assets?.social && Object.keys(assets.social).length > 0
assets?.social && Object.keys(assets.social).length > 0 && !scamInfo
? {
title: 'Other Links',
value: <SocialIcons assets={assets.social} excludeWebsite />
}
: {},
{ title: 'Type', value: <NftBadge type={type} /> },
!assets && ticker !== name ? { title: 'Name', value: name } : {},
!scamInfo ? { title: 'Type', value: <NftBadge type={type} /> } : {},
!assets && ticker !== name && !scamInfo
? { title: 'Name', value: name }
: {},
{ title: 'Collection', value: collection },
decimals !== undefined
? {
Expand Down
18 changes: 11 additions & 7 deletions src/layouts/NftLayout/NftDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const NftDetailsCard = () => {
</Overlay>
}
detailItems={[
description
Boolean(description && (!scamInfo || showData))
? {
title: 'Description',
value: (
Expand All @@ -129,7 +129,7 @@ export const NftDetailsCard = () => {
)
}
: {},
hasExtraDescription
hasExtraDescription && (!scamInfo || showData)
? {
title: 'Collection',
value: (
Expand All @@ -142,20 +142,24 @@ export const NftDetailsCard = () => {
)
}
: {},
assets?.website
assets?.website && (!scamInfo || showData)
? {
title: 'Website',
value: <SocialWebsite link={assets.website} />
}
: {},
assets?.social && Object.keys(assets.social).length > 0
assets?.social &&
Object.keys(assets.social).length > 0 &&
(!scamInfo || showData)
? {
title: 'Other Links',
value: <SocialIcons assets={assets.social} excludeWebsite />
}
: {},
{ title: 'Type', value: <NftBadge type={type} /> },
!assets && ticker !== name ? { title: 'Name', value: name } : {},
!assets && ticker !== name && (!scamInfo || showData)
? { title: 'Name', value: name }
: {},
{ title: 'Collection', value: <CollectionBlock nft={nftState} /> },
{ title: 'Identifier', value: identifier },
decimals !== undefined
Expand All @@ -167,12 +171,12 @@ export const NftDetailsCard = () => {
owner !== undefined
? {
title: 'Owner',
value: <AccountLink address={owner} fetchAssets />
value: <AccountLink address={owner} fetchAssets={!scamInfo} />
}
: {},
{
title: 'Creator',
value: <AccountLink address={creator} fetchAssets />
value: <AccountLink address={creator} fetchAssets={!scamInfo} />
},
timestamp !== undefined
? {
Expand Down
28 changes: 16 additions & 12 deletions src/pages/TransactionDetails/TransactionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,29 @@ export const TransactionDetails = () => {
const [dataReady, setDataReady] = useState<boolean | undefined>();

const fetchTransaction = async () => {
if (transactionId) {
if (transactionId && isHash(transactionId)) {
const { data, success } = await getTransaction(transactionId);
if (!success && !data && isHash(transactionId)) {
let originalTxHash = data?.originalTxHash;

if (!success && !data) {
const { data: scData, success: scSuccess } = await getScResult(
transactionId
);
if (scData?.originalTxHash && scData.hash && scSuccess) {
const options = {
pathname: networkRoute(
urlBuilder.transactionDetails(scData.originalTxHash)
),
hash: scData.hash
};
navigate(options, { replace: true });

return;
if (scSuccess) {
originalTxHash = scData?.originalTxHash;
}
}

if (originalTxHash) {
const options = {
pathname: networkRoute(urlBuilder.transactionDetails(originalTxHash)),
hash: transactionId
};
navigate(options, { replace: true });

return;
}

setTransaction(data);
setDataReady(success);
}
Expand Down
5 changes: 4 additions & 1 deletion src/types/transaction.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ export enum TransactionMethodsEnum {
// guardian
SetGuardian = 'SetGuardian',
GuardAccount = 'GuardAccount',
UnGuardAccount = 'UnGuardAccount'
UnGuardAccount = 'UnGuardAccount',
// xportal
claim = 'claim',
openMysteryBox = 'openMysteryBox'
}

export interface EventType {
Expand Down

0 comments on commit 45c6649

Please sign in to comment.