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-1387 Implement sending EVM tokens #1219

Open
wants to merge 96 commits into
base: development-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
e7563e1
basic layout
lendihop Aug 27, 2024
a63115b
select token for tezos
lendihop Aug 29, 2024
39abe25
select token
lendihop Sep 3, 2024
f7c46de
dont show tags
lendihop Sep 3, 2024
804f710
fix select asset modal opening after page reload
lendihop Sep 4, 2024
689abf0
fix e2e ts
lendihop Sep 4, 2024
4e9c512
form refactor
lendihop Sep 5, 2024
d247267
resolving evm address from domain
lendihop Sep 5, 2024
6e97893
max amount calculation
lendihop Sep 8, 2024
996b7fe
fix logic for erc20 tokens
lendihop Sep 8, 2024
f72cee4
recipient account select main logic
lendihop Sep 9, 2024
eb334c6
address copying fixed
lendihop Sep 10, 2024
ffa5410
recipient input / select acc state connection + truncation added
lendihop Sep 10, 2024
6d4aa03
tezos form validation fixes
lendihop Sep 10, 2024
5d5192d
evm form validation + react-hook-form v7 used
lendihop Sep 12, 2024
e570f93
add active state for filter network option
lendihop Sep 12, 2024
7b3cc12
scroll to selected network
lendihop Sep 12, 2024
690438f
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Sep 13, 2024
8ddb14c
add filter network search
lendihop Sep 17, 2024
73c009e
loader added
lendihop Sep 17, 2024
644f213
always show converted amount
lendihop Sep 17, 2024
ad1da2e
show floating assetSymbol in input
lendihop Sep 18, 2024
0c21a84
track other networks addresses
lendihop Sep 18, 2024
d654a2e
show tezos error toast on form submit
lendihop Sep 18, 2024
5860f3f
maxAmount calculation fixes
lendihop Sep 18, 2024
f20b16f
fix pipeline
lendihop Sep 18, 2024
ff3d019
confirm modal base + segmented control
lendihop Sep 18, 2024
bd25713
confirmation modal layout finished
lendihop Sep 19, 2024
5d8fe51
Evm / tezos component separation Header, DetailsTab
lendihop Sep 20, 2024
98ac994
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Sep 23, 2024
1279fa7
fix after-merge conflicts
lendihop Sep 23, 2024
94d04dc
fix network icon
lendihop Sep 23, 2024
a877d1f
more after-merge fixes
lendihop Sep 23, 2024
876f9df
some more fixes
lendihop Sep 23, 2024
4b8c7c7
some more fixes
lendihop Sep 23, 2024
12ef9cd
infoIcon
lendihop Sep 23, 2024
913085d
iconBase memo
lendihop Sep 23, 2024
ed1e0fc
viem update
lendihop Sep 23, 2024
e628332
send evm transaction
lendihop Sep 24, 2024
f322519
send evm transaction / add networks support
lendihop Sep 25, 2024
82abb92
fix various ui bugs
lendihop Sep 26, 2024
f648625
fix fee options calculations
lendihop Sep 26, 2024
bafe37c
fix some more bugs
lendihop Sep 27, 2024
b5c8acf
fix import cycle
lendihop Sep 27, 2024
96b7626
custom transaction params inputs + error handling
lendihop Sep 29, 2024
78b647b
fix ts-prune
lendihop Sep 29, 2024
2000b34
major refactoring and bug fixes
lendihop Oct 2, 2024
4e5d58e
tezos fee options calculation + ui fixes
lendihop Oct 2, 2024
5b79b43
send tezos operations without old confirmation page
lendihop Oct 6, 2024
13623e3
added loading button + proper form reset
lendihop Oct 6, 2024
134cdaf
edit gas fee and storageLimit
lendihop Oct 7, 2024
62bc3d0
show default evm form values
lendihop Oct 7, 2024
083ca2f
some ui fixes
lendihop Oct 8, 2024
0e696a8
non zero validation
lendihop Oct 8, 2024
5a1727a
error tab
lendihop Oct 8, 2024
9561c5c
fix ts-prune
lendihop Oct 8, 2024
063bb51
fix fee calculation with custom gas limit
lendihop Oct 8, 2024
b726cea
refactor
lendihop Oct 10, 2024
f30e851
refactor + minor ui fixes
lendihop Oct 10, 2024
4cbeccb
show default gas fee and storage limit + non zero gas fee validation
lendihop Oct 10, 2024
4765994
storage limit handling
lendihop Oct 10, 2024
0226d97
fix ts-prune
lendihop Oct 10, 2024
e4143b1
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Oct 10, 2024
04b33b8
fix some after-merge issues
lendihop Oct 10, 2024
3824fd7
show tezos raw transaction
lendihop Oct 10, 2024
d93dcae
renaming
lendihop Oct 11, 2024
52b12b6
raw transaction json view
lendihop Oct 11, 2024
568d1b1
tezos submit errors handling
lendihop Oct 11, 2024
9b01fa8
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Oct 11, 2024
8db086c
fix some after-merge issues
lendihop Oct 11, 2024
39110d7
fix some after-merge issues
lendihop Oct 11, 2024
9b05f98
fix ts-prune
lendihop Oct 11, 2024
3439367
refactor
lendihop Oct 16, 2024
485edc1
more refactor
lendihop Oct 17, 2024
465900a
apply suggestion
lendihop Oct 17, 2024
19c4d5b
fix audit
lendihop Oct 25, 2024
bd6e641
minor bug fixes
lendihop Oct 29, 2024
a8ae54f
Merge branch 'refs/heads/development-2' into TW-1385-gas-token-send-r…
lendihop Oct 29, 2024
6be2621
after merge fixes
lendihop Oct 29, 2024
9c7a4a7
fix minor bugs
lendihop Oct 30, 2024
39ba572
resolve merge conflicts
lendihop Oct 31, 2024
bdac7fd
some more after-merge fixes
lendihop Oct 31, 2024
d0c8ba4
some more after-merge fixes
lendihop Oct 31, 2024
06b60c0
fix info icon size
lendihop Oct 31, 2024
10f285a
TW-1387 Implement sending ERC20 tokens
keshan3262 Nov 1, 2024
997d946
TW-1387 Implement sending ERC721 and ERC1155 tokens
keshan3262 Nov 4, 2024
fa2f33f
TW-1387 Resolve merge conflicts
keshan3262 Nov 4, 2024
998cecd
TW-1387 Fix pipeline errors
keshan3262 Nov 4, 2024
37814a6
TW-1387 Major refactoring
keshan3262 Nov 4, 2024
1194526
TW-1387 Fix displaying transaction hex
keshan3262 Nov 4, 2024
8fc345a
Merge branch 'development-2' of https://github.com/madfish-solutions/…
keshan3262 Nov 6, 2024
343a078
TW-1387 Refactoring according to comments
keshan3262 Nov 6, 2024
02985c4
Merge branch 'development-2' of https://github.com/madfish-solutions/…
keshan3262 Nov 7, 2024
a7d5c5b
TW-1387 Refactoring according to comments
keshan3262 Nov 7, 2024
220f117
Merge branch 'development-2' of https://github.com/madfish-solutions/…
keshan3262 Nov 11, 2024
cb30429
TW-1387 Improve balances update in networks that are not covered by C…
keshan3262 Nov 15, 2024
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
30 changes: 0 additions & 30 deletions src/app/atoms/Loader.tsx

This file was deleted.

37 changes: 20 additions & 17 deletions src/app/hooks/listing-logic/use-account-tokens-listing-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,26 @@ export const useAccountTokensForListing = (
[enabledEvmChains, enabledTezChains]
);

const enabledChainsSlugsSorted = useMemoWithCompare(() => {
const enabledChainsSlugs = [
...gasChainsSlugs,
...tezTokens
.filter(({ status }) => status === 'enabled')
.map(({ chainId, slug }) => toChainAssetSlug(TempleChainKind.Tezos, chainId, slug)),
...evmTokens
.filter(({ status }) => status === 'enabled')
.map(({ chainId, slug }) => toChainAssetSlug(TempleChainKind.EVM, chainId, slug))
];

const enabledChainsSlugsFiltered = filterZeroBalances
? enabledChainsSlugs.filter(isNonZeroBalance)
: enabledChainsSlugs;

return enabledChainsSlugsFiltered.sort(tokensSortPredicate);
}, [gasChainsSlugs, tezTokens, evmTokens, filterZeroBalances, isNonZeroBalance, tokensSortPredicate]);
const enabledChainsSlugsFiltered = useMemo(() => {
const enabledChainsSlugs = gasChainsSlugs
.concat(
tezTokens
.filter(({ status }) => status === 'enabled')
.map(({ chainId, slug }) => toChainAssetSlug(TempleChainKind.Tezos, chainId, slug))
)
.concat(
evmTokens
.filter(({ status }) => status === 'enabled')
.map(({ chainId, slug }) => toChainAssetSlug(TempleChainKind.EVM, chainId, slug))
);

return filterZeroBalances ? enabledChainsSlugs.filter(isNonZeroBalance) : enabledChainsSlugs;
}, [evmTokens, filterZeroBalances, gasChainsSlugs, isNonZeroBalance, tezTokens]);

const enabledChainsSlugsSorted = useMemoWithCompare(
() => enabledChainsSlugsFiltered.sort(tokensSortPredicate),
[enabledChainsSlugsFiltered, tokensSortPredicate]
);

return {
enabledChainsSlugsSorted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ export const useEvmChainAccountTokensForListing = (
[balances]
);

const enabledSlugsSorted = useMemoWithCompare(() => {
const enabledSlugs = [
EVM_TOKEN_SLUG,
...tokens.filter(({ status }) => status === 'enabled').map(({ slug }) => slug)
];

const enabledSlugsFiltered = filterZeroBalances ? enabledSlugs.filter(isNonZeroBalance) : enabledSlugs;

return enabledSlugsFiltered.sort(tokensSortPredicate);
}, [tokens, isNonZeroBalance, tokensSortPredicate, filterZeroBalances]);
const enabledSlugsFiltered = useMemo(() => {
const gasTokensSlugs: string[] = [EVM_TOKEN_SLUG];
const enabledSlugs = gasTokensSlugs.concat(
tokens.filter(({ status }) => status === 'enabled').map(({ slug }) => slug)
);

return filterZeroBalances ? enabledSlugs.filter(isNonZeroBalance) : enabledSlugs;
}, [filterZeroBalances, isNonZeroBalance, tokens]);

const enabledSlugsSorted = useMemoWithCompare(
() => enabledSlugsFiltered.sort(tokensSortPredicate),
[enabledSlugsFiltered, tokensSortPredicate]
);

return {
enabledSlugsSorted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ export const useTezosAccountTokensForListing = (publicKeyHash: string, filterZer
[balancesRecord, publicKeyHash]
);

const enabledChainsSlugsSorted = useMemoWithCompare(() => {
const enabledSlugsFiltered = useMemo(() => {
const enabledSlugs = gasSlugs.concat(enabledStoredChainSlugs);

const enabledSlugsFiltered = filterZeroBalances ? enabledSlugs.filter(isNonZeroBalance) : enabledSlugs;
return filterZeroBalances ? enabledSlugs.filter(isNonZeroBalance) : enabledSlugs;
}, [enabledStoredChainSlugs, filterZeroBalances, gasSlugs, isNonZeroBalance]);

return enabledSlugsFiltered.sort(tokensSortPredicate);
}, [enabledStoredChainSlugs, isNonZeroBalance, tokensSortPredicate, gasSlugs, filterZeroBalances]);
const enabledChainsSlugsSorted = useMemoWithCompare(
() => enabledSlugsFiltered.sort(tokensSortPredicate),
[enabledSlugsFiltered, tokensSortPredicate]
);

return {
enabledChainsSlugsSorted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ export const useTezosChainAccountTokensForListing = (publicKeyHash: string, chai
[isNonZeroBalance, leadingAssetsSlugs, filterZeroBalances]
);

const nonLeadingTokenSlugsFilteredSorted = useMemoWithCompare(() => {
const nonLeadingSlugs = [
TEZ_TOKEN_SLUG,
...tokens.filter(({ status }) => status === 'enabled').map(({ slug }) => slug)
];

return (filterZeroBalances ? nonLeadingSlugs.filter(isNonZeroBalance) : nonLeadingSlugs).sort(tokensSortPredicate);
}, [tokens, isNonZeroBalance, tokensSortPredicate, filterZeroBalances]);
const nonLeadingTokensSlugsFiltered = useMemo(() => {
const gasSlugs: string[] = [TEZ_TOKEN_SLUG];
const nonLeadingSlugs = gasSlugs.concat(
tokens.filter(({ status }) => status === 'enabled').map(({ slug }) => slug)
);

return filterZeroBalances ? nonLeadingSlugs.filter(isNonZeroBalance) : nonLeadingSlugs;
}, [tokens, isNonZeroBalance, filterZeroBalances]);

const nonLeadingTokenSlugsFilteredSorted = useMemoWithCompare(
() => nonLeadingTokensSlugsFiltered.sort(tokensSortPredicate),
[nonLeadingTokensSlugsFiltered, tokensSortPredicate]
);

const enabledTokenSlugsSorted = useMemo(
() => Array.from(new Set(leadingAssetsFiltered.concat(nonLeadingTokenSlugsFilteredSorted))),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';

import { isString } from 'lodash';

import { Model3DViewer } from 'app/atoms/Model3DViewer';
import { useCollectiblesListOptionsSelector } from 'app/store/assets-filter-options/selectors';
import { TezosAssetImage } from 'app/templates/AssetImage';
import { isSvgDataUriInUtf8Encoding, buildObjktCollectibleArtifactUri } from 'lib/images-uri';
import { isSvgDataUriInUtf8Encoding, buildObjktCollectibleArtifactUri, buildHttpLinkFromUri } from 'lib/images-uri';
import { TokenMetadata } from 'lib/metadata';
import { EvmCollectibleMetadata } from 'lib/metadata/types';
import { ImageStacked } from 'lib/ui/ImageStacked';
Expand Down Expand Up @@ -103,7 +105,9 @@ interface EvmCollectiblePageImageProps {
}

export const EvmCollectiblePageImage = memo<EvmCollectiblePageImageProps>(({ metadata, className }) => {
const sources = useMemo(() => (metadata.image ? [metadata.image] : []), [metadata.image]);
const { image } = metadata;

const sources = useMemo(() => [buildHttpLinkFromUri(image)].filter(isString), [image]);

return (
<ImageStacked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import React, { memo, useMemo } from 'react';
import BigNumber from 'bignumber.js';

import { OldStyleHashChip, ExternalLinkChip } from 'app/atoms';
import { useRawEvmAssetBalanceSelector } from 'app/store/evm/balances/selectors';
import type { CollectibleDetails } from 'app/store/tezos/collectibles/state';
import { fromFa2TokenSlug } from 'lib/assets/utils';
import { useTezosAssetBalance } from 'lib/balances';
import { useEvmAssetBalance } from 'lib/balances/hooks';
import { formatDate } from 'lib/i18n';
import { EvmCollectibleMetadata } from 'lib/metadata/types';
import { useBlockExplorerHref } from 'temple/front/block-explorers';
import { useEvmChainByChainId } from 'temple/front/chains';
import { TezosNetworkEssentials } from 'temple/networks';
import { TempleChainKind } from 'temple/types';

Expand Down Expand Up @@ -109,15 +110,16 @@ interface EvmPropertiesItemsProps {
}

export const EvmPropertiesItems = memo<EvmPropertiesItemsProps>(({ accountPkh, evmChainId, assetSlug, metadata }) => {
const rawBalance = useRawEvmAssetBalanceSelector(accountPkh, evmChainId, assetSlug);
const chain = useEvmChainByChainId(evmChainId);
const { value: balance } = useEvmAssetBalance(assetSlug, accountPkh, chain!);

if (!metadata) return null;

return (
<>
<div className={itemClassName}>
<h6 className={itemTitleClassName}>Owned</h6>
<span className={itemValueClassName}>{rawBalance ?? '-'}</span>
<span className={itemValueClassName}>{balance?.toFixed() ?? '-'}</span>
</div>

<div className={itemClassName}>
Expand Down
9 changes: 9 additions & 0 deletions src/app/pages/Collectibles/CollectiblePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ const EvmCollectiblePage = memo<EvmCollectiblePageProps>(({ evmChainId, assetSlu
return tab ?? tabs[0]!;
}, [tabs, tabNameInUrl]);

const onSendButtonClick = useCallback(
() => navigate(buildSendPagePath(TempleChainKind.EVM, String(evmChainId), assetSlug)),
[evmChainId, assetSlug]
);

return (
<PageLayout
pageTitle={
Expand Down Expand Up @@ -128,6 +133,10 @@ const EvmCollectiblePage = memo<EvmCollectiblePageProps>(({ evmChainId, assetSlu
</div>
)}

<FormSubmitButton onClick={onSendButtonClick} testID={CollectiblesSelectors.sendButton}>
<T id="send" />
</FormSubmitButton>

<TabsBar tabs={tabs} activeTabName={activeTabName} withOutline />

<div className="grid grid-cols-2 gap-2 text-gray-910">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ReactComponent as DeleteIcon } from 'app/icons/base/delete.svg';
import { dispatch } from 'app/store';
import { setEvmCollectibleStatusAction } from 'app/store/evm/assets/actions';
import { useStoredEvmCollectibleSelector } from 'app/store/evm/assets/selectors';
import { useRawEvmAssetBalanceSelector } from 'app/store/evm/balances/selectors';
import { useEvmCollectibleMetadataSelector } from 'app/store/evm/collectibles-metadata/selectors';
import { setTezosCollectibleStatusAction } from 'app/store/tezos/assets/actions';
import { useStoredTezosCollectibleSelector } from 'app/store/tezos/assets/selectors';
Expand All @@ -25,13 +24,15 @@ import { DeleteAssetModal } from 'app/templates/remove-asset-modal/delete-asset-
import { setAnotherSelector, setTestID } from 'lib/analytics';
import { objktCurrencies } from 'lib/apis/objkt';
import { getAssetStatus } from 'lib/assets/hooks/utils';
import { useEvmAssetBalance } from 'lib/balances/hooks';
import { T } from 'lib/i18n';
import { getTokenName } from 'lib/metadata';
import { getCollectibleName, getCollectionName } from 'lib/metadata/utils';
import { atomsToTokens } from 'lib/temple/helpers';
import { TEZOS_MAINNET_CHAIN_ID } from 'lib/temple/types';
import { useBooleanState } from 'lib/ui/hooks';
import useTippy, { UseTippyOptions } from 'lib/ui/useTippy';
import { ZERO } from 'lib/utils/numbers';
import { Link } from 'lib/woozie';
import { useEvmChainByChainId, useTezosChainByChainId } from 'temple/front/chains';
import { TempleChainKind } from 'temple/types';
Expand Down Expand Up @@ -278,12 +279,13 @@ interface EvmCollectibleItemProps {
export const EvmCollectibleItem = memo<EvmCollectibleItemProps>(
({ assetSlug, evmChainId, accountPkh, showDetails = false, manageActive = false, hideWithoutMeta }) => {
const metadata = useEvmCollectibleMetadataSelector(evmChainId, assetSlug);
const balanceAtomic = useRawEvmAssetBalanceSelector(accountPkh, evmChainId, assetSlug);
const balance = balanceAtomic ?? '0';
const chain = useEvmChainByChainId(evmChainId);
const { value: balance = ZERO } = useEvmAssetBalance(assetSlug, accountPkh, chain!);
const balanceBeforeTruncate = balance.toString();

const storedToken = useStoredEvmCollectibleSelector(accountPkh, evmChainId, assetSlug);

const checked = getAssetStatus(balance, storedToken?.status) === 'enabled';
const checked = getAssetStatus(balanceBeforeTruncate, storedToken?.status) === 'enabled';

const [deleteModalOpened, setDeleteModalOpened, setDeleteModalClosed] = useBooleanState(false);

Expand Down Expand Up @@ -313,7 +315,10 @@ export const EvmCollectibleItem = memo<EvmCollectibleItemProps>(
[checked, assetSlug, evmChainId, accountPkh]
);

const truncatedBalance = useMemo(() => (balance.length > 6 ? `${balance.slice(0, 6)}...` : balance), [balance]);
const truncatedBalance = useMemo(
() => (balanceBeforeTruncate.length > 6 ? `${balanceBeforeTruncate.slice(0, 6)}...` : balanceBeforeTruncate),
[balanceBeforeTruncate]
);

const network = useEvmChainByChainId(evmChainId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { t, T } from 'lib/i18n';
import { isCollectible, TokenMetadata } from 'lib/metadata';
import { fetchOneTokenMetadata } from 'lib/metadata/fetch';
import { TokenMetadataNotFoundError } from 'lib/metadata/on-chain';
import { EvmTokenMetadata } from 'lib/metadata/types';
import { EvmCollectibleMetadata, EvmTokenMetadata } from 'lib/metadata/types';
import { loadContract } from 'lib/temple/contract';
import { useSafeState } from 'lib/ui/hooks';
import { navigate } from 'lib/woozie';
Expand Down Expand Up @@ -69,11 +69,14 @@ interface RequiredTokenMetadataResponse extends TokenMetadataResponse {
symbol: string;
}

interface RequiredEvmTokenMetadata extends EvmTokenMetadata {
interface RequiredMetadata {
name: string;
symbol: string;
}

type RequiredEvmTokenMetadata = EvmTokenMetadata & RequiredMetadata;
type RequiredEvmCollectibleMetadata = EvmCollectibleMetadata & RequiredMetadata;

interface FormData {
address: string;
id?: string;
Expand Down Expand Up @@ -125,7 +128,7 @@ export const AddTokenForm = memo<AddTokenPageProps>(

const attemptRef = useRef(0);
const tezMetadataRef = useRef<RequiredTokenMetadataResponse>();
const evmMetadataRef = useRef<RequiredEvmTokenMetadata>();
const evmMetadataRef = useRef<RequiredEvmTokenMetadata | RequiredEvmCollectibleMetadata>();

const loadMetadataPure = useCallback(async () => {
if (!formValid) return;
Expand Down Expand Up @@ -173,10 +176,10 @@ export const AddTokenForm = memo<AddTokenPageProps>(
? fetchEvmCollectibleMetadataFromChain
: fetchEvmTokenMetadataFromChain)(selectedNetwork, tokenSlug);

if (!metadata || !metadata.name || !metadata.symbol)
if (!metadata || !hasRequiredMetadata(metadata))
throw new TokenMetadataNotFoundError('Failed to load token metadata');

evmMetadataRef.current = metadata as RequiredEvmTokenMetadata;
evmMetadataRef.current = metadata;

stateToSet = { bottomSectionVisible: true };
}
Expand Down Expand Up @@ -285,14 +288,16 @@ export const AddTokenForm = memo<AddTokenPageProps>(
dispatch(
putEvmCollectiblesMetadataAction({
chainId: selectedNetwork.chainId,
records: { [tokenSlug]: { ...evmMetadataRef.current, tokenId: id } }
records: {
[tokenSlug]: { ...(evmMetadataRef.current as RequiredEvmCollectibleMetadata), tokenId: id }
}
})
);
else
dispatch(
putEvmTokensMetadataAction({
chainId: selectedNetwork.chainId,
records: { [tokenSlug]: evmMetadataRef.current }
records: { [tokenSlug]: evmMetadataRef.current as RequiredEvmTokenMetadata }
})
);
}
Expand Down Expand Up @@ -422,6 +427,10 @@ export const AddTokenForm = memo<AddTokenPageProps>(
}
);

const hasRequiredMetadata = (
metadata: EvmTokenMetadata | EvmCollectibleMetadata
): metadata is RequiredEvmCollectibleMetadata | RequiredEvmTokenMetadata => Boolean(metadata.name && metadata.symbol);

const errorHandler = (err: any, contractAddress: string) => {
if (err instanceof ContractNotFoundError) {
toastError(t('referredByTokenContractNotFound', contractAddress));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ const TabContentWithManageActive: FC<TabContentProps> = ({ publicKeyHash, networ
hideZeroBalance
);

const storedSlugs = useMemo(
() => tokens.filter(({ status }) => status !== 'removed').map(({ slug }) => slug),
[tokens]
);

const allStoredSlugsSorted = useMemoWithCompare(
() =>
tokens
.filter(({ status }) => status !== 'removed')
.map(({ slug }) => slug)
.sort(tokensSortPredicate),
[tokens, tokensSortPredicate]
() => storedSlugs.sort(tokensSortPredicate),
[storedSlugs, tokensSortPredicate]
);

const allSlugsSorted = usePreservedOrderSlugsToManage(enabledSlugsSorted, allStoredSlugsSorted);
Expand Down
Loading
Loading