From 425fad9352365eb2ed9ab1fb43b4dbd15f50c191 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 Oct 2023 16:05:32 +0300 Subject: [PATCH] TW-683: Assets rework. Refactor --- .../pages/Collectibles/CollectiblesTab/index.tsx | 1 - src/app/pages/ManageAssets/ListItem.tsx | 2 +- src/app/store/assets/utils.ts | 2 -- src/lib/apis/temple/metadata.ts | 1 - src/lib/apis/tzkt/api.ts | 15 ++++++--------- src/lib/assets/hooks/collectibles.ts | 1 - src/lib/metadata/utils.ts | 1 - 7 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/app/pages/Collectibles/CollectiblesTab/index.tsx b/src/app/pages/Collectibles/CollectiblesTab/index.tsx index de4ee6e9f..ba4f00615 100644 --- a/src/app/pages/Collectibles/CollectiblesTab/index.tsx +++ b/src/app/pages/Collectibles/CollectiblesTab/index.tsx @@ -43,7 +43,6 @@ export const CollectiblesTab = memo(({ scrollToTheTabsBar }) => { const toggleDetailsShown = useCallback(() => void setDetailsShown(val => !val), [setDetailsShown]); const slugs = useEnabledAccountCollectiblesSlugs(); - console.log('slugs:', slugs); const { filteredAssets, searchValue, setSearchValue } = useFilteredAssetsSlugs(slugs, false); diff --git a/src/app/pages/ManageAssets/ListItem.tsx b/src/app/pages/ManageAssets/ListItem.tsx index e26bceb5c..e54aa95a0 100644 --- a/src/app/pages/ManageAssets/ListItem.tsx +++ b/src/app/pages/ManageAssets/ListItem.tsx @@ -14,7 +14,7 @@ type Props = { assetSlug: string; last: boolean; checked: boolean; - onToggle: (slug: string, toDisable: boolean) => void; + onToggle: (slug: string, newState: boolean) => void; onRemove: (slug: string) => void; }; diff --git a/src/app/store/assets/utils.ts b/src/app/store/assets/utils.ts index c7115fc8f..9a0cf2000 100644 --- a/src/app/store/assets/utils.ts +++ b/src/app/store/assets/utils.ts @@ -48,8 +48,6 @@ const finishAssetsLoading = async ( return knownMeta[slug] ? acc : acc.concat(slug); }, []); - console.log('fuck', fungibleByMetaCheck, data.length, slugsWithoutMeta); - const newMetadatas = isKnownChainId(chainId) ? await fetchTokensMetadata(chainId, slugsWithoutMeta).catch(err => { console.error(err); diff --git a/src/lib/apis/temple/metadata.ts b/src/lib/apis/temple/metadata.ts index 6f63e44f1..b4aa6e03c 100644 --- a/src/lib/apis/temple/metadata.ts +++ b/src/lib/apis/temple/metadata.ts @@ -29,7 +29,6 @@ export interface TokenMetadataResponse { artifactUri?: string; displayUri?: string; image?: string; - // standard?: 'fa2' | 'fa12'; } export const fetchOneTokenMetadata = (chainId: MetadataApiChainId, address: string, id = 0) => diff --git a/src/lib/apis/tzkt/api.ts b/src/lib/apis/tzkt/api.ts index bc3868c11..4613b7c80 100644 --- a/src/lib/apis/tzkt/api.ts +++ b/src/lib/apis/tzkt/api.ts @@ -123,16 +123,14 @@ export const getDelegatorRewards = ( const TZKT_MAX_QUERY_ITEMS_LIMIT = 10_000; -export function fetchTzktAccountAssets( - account: string, - chainId: string, - /** `null` for unknown */ - fungible: boolean | null -): Promise { +/** + * @arg fungible // `null` for unknown fungibility only + */ +export function fetchTzktAccountAssets(account: string, chainId: string, fungible: boolean | null) { if (!isKnownChainId(chainId)) return Promise.resolve([]); const recurse = async (accum: TzktAccountAsset[], offset: number): Promise => { - const data = await fetchTzktAccountAssetsOnce(account, chainId, offset, fungible); + const data = await fetchTzktAccountAssetsPage(account, chainId, offset, fungible); if (!data.length) return accum; @@ -145,7 +143,7 @@ export function fetchTzktAccountAssets( return recurse([], 0); } -const fetchTzktAccountAssetsOnce = ( +const fetchTzktAccountAssetsPage = ( account: string, chainId: TzktApiChainId, offset?: number, @@ -158,7 +156,6 @@ const fetchTzktAccountAssetsOnce = ( ...(fungible === null ? { 'token.metadata.null': true } : { - // 'token.metadata.decimals.null': false, // (do) 'token.metadata.artifactUri.null': fungible }), 'sort.desc': 'balance' diff --git a/src/lib/assets/hooks/collectibles.ts b/src/lib/assets/hooks/collectibles.ts index 551f9392e..13817dc88 100644 --- a/src/lib/assets/hooks/collectibles.ts +++ b/src/lib/assets/hooks/collectibles.ts @@ -19,7 +19,6 @@ export const useAccountCollectibles = (account: string, chainId: string) => { const stored = useAccountAssetsSelector(account, chainId, 'collectibles'); const balances = useBalancesSelector(account, chainId); - console.log('FUCK', stored, balances); return useMemoWithCompare( () => diff --git a/src/lib/metadata/utils.ts b/src/lib/metadata/utils.ts index 80a42e8f7..d398cddc1 100644 --- a/src/lib/metadata/utils.ts +++ b/src/lib/metadata/utils.ts @@ -12,7 +12,6 @@ export const buildTokenMetadataFromFetched = ( address, id, ...pick(token, ['decimals', 'thumbnailUri', 'displayUri', 'artifactUri']), - // standard: token.standard === 'fa2' ? TokenStandardsEnum.Fa2 : TokenStandardsEnum.Fa12, symbol: token.symbol ?? token.name?.substring(0, 8) ?? '???', name: token.name ?? token.symbol ?? 'Unknown Token' });