Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1116: Fix pre-release #1004

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
}
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"react-hooks/rules-of-hooks": "warn",
"react-hooks/exhaustive-deps": "warn"
}
Expand Down
13 changes: 9 additions & 4 deletions src/app/pages/Collectibles/CollectiblePage/PropertiesItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ interface PropertiesItemsProps {
}

export const PropertiesItems = memo<PropertiesItemsProps>(({ assetSlug, accountPkh, details }) => {
const { contract, id } = fromFa2TokenSlug(assetSlug);

const { data: balance } = useBalance(assetSlug, accountPkh, {
suspense: false
});
const { account: accountExplorerBaseUrl } = useExplorerBaseUrls();

const { transaction: explorerBaseUrl } = useExplorerBaseUrls();
const exploreContractUrl = useMemo(
() => (explorerBaseUrl ? new URL(contract, explorerBaseUrl).href : null),
[explorerBaseUrl, contract]
);

const mintedTimestamp = useMemo(() => {
const value = details?.mintedTimestamp;
Expand All @@ -34,8 +41,6 @@ export const PropertiesItems = memo<PropertiesItemsProps>(({ assetSlug, accountP
return `${royalties.toString()}%`;
}, [details]);

const { contract, id } = fromFa2TokenSlug(assetSlug);

const itemClassName = 'flex flex-col gap-y-2 p-3 border border-gray-300 rounded-md';
const itemTitleClassName = 'text-xs text-gray-600 leading-5';
const itemValueClassName = 'text-base font-semibold leading-5 break-words';
Expand Down Expand Up @@ -72,7 +77,7 @@ export const PropertiesItems = memo<PropertiesItemsProps>(({ assetSlug, accountP
className="tracking-tighter"
rounded="base"
/>
<ExternalLinkChip href={new URL(contract, accountExplorerBaseUrl).href} tooltip="Explore contract" />
{exploreContractUrl && <ExternalLinkChip href={exploreContractUrl} tooltip="Explore contract" />}
</div>
</div>

Expand Down
9 changes: 7 additions & 2 deletions src/app/pages/Home/OtherComponents/Tokens/Tokens.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';

import { ChainIds } from '@taquito/taquito';
import { BigNumber } from 'bignumber.js';
import clsx from 'clsx';
import { isEqual } from 'lodash';
Expand Down Expand Up @@ -35,7 +36,6 @@ import { toExploreAssetLink } from './utils';

const LOCAL_STORAGE_TOGGLE_KEY = 'tokens-list:hide-zero-balances';
const svgIconClassName = 'w-4 h-4 stroke-current fill-current text-gray-600';
const LEADING_ASSETS = [TEZ_TOKEN_SLUG, TEMPLE_TOKEN_SLUG];

export const TokensTab: FC = () => {
const dispatch = useDispatch();
Expand All @@ -57,10 +57,15 @@ export const TokensTab: FC = () => {

const slugs = useMemoWithCompare(() => tokens.map(({ tokenSlug }) => tokenSlug).sort(), [tokens], isEqual);

const leadingAssets = useMemo(
() => (chainId === ChainIds.MAINNET ? [TEZ_TOKEN_SLUG, TEMPLE_TOKEN_SLUG] : [TEZ_TOKEN_SLUG]),
[chainId]
);

const { filteredAssets, searchValue, setSearchValue } = useFilteredAssetsSlugs(
slugs,
isZeroBalancesHidden,
LEADING_ASSETS
leadingAssets
);

const isEnabledAdsBanner = useIsEnabledAdsBannerSelector();
Expand Down
17 changes: 12 additions & 5 deletions src/lib/temple/front/blockexplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { isKnownChainId, TempleChainId } from 'lib/temple/types';

type BlockExplorerId = 'tzkt' | 'tzstats' | 'bcd' | 't4l3nt';

type BaseUrls = { account?: string; transaction: string; api?: string };
interface BaseUrls {
account?: string;
transaction: string;
api?: string;
}

export type BlockExplorer = {
id: BlockExplorerId;
Expand Down Expand Up @@ -115,8 +119,11 @@ export function useExplorerBaseUrls(): Partial<BaseUrls> {
const chainId = useChainId();
const { explorer } = useBlockExplorer();

if (chainId && isKnownChainId(chainId)) {
return explorer.baseUrls.get(chainId) ?? {};
}
return {};
return useMemo(() => {
if (chainId && isKnownChainId(chainId)) {
return explorer.baseUrls.get(chainId) ?? {};
}

return {};
}, [chainId, explorer]);
}
Loading