Skip to content

Commit

Permalink
TW-683: Assets rework. Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tsx committed Oct 2, 2023
1 parent 2e62d4f commit 425fad9
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/app/pages/Collectibles/CollectiblesTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const CollectiblesTab = memo<Props>(({ scrollToTheTabsBar }) => {
const toggleDetailsShown = useCallback(() => void setDetailsShown(val => !val), [setDetailsShown]);

const slugs = useEnabledAccountCollectiblesSlugs();
console.log('slugs:', slugs);

const { filteredAssets, searchValue, setSearchValue } = useFilteredAssetsSlugs(slugs, false);

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/ManageAssets/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
2 changes: 0 additions & 2 deletions src/app/store/assets/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/lib/apis/temple/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
15 changes: 6 additions & 9 deletions src/lib/apis/tzkt/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TzktAccountAsset[]> {
/**
* @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<TzktAccountAsset[]> => {
const data = await fetchTzktAccountAssetsOnce(account, chainId, offset, fungible);
const data = await fetchTzktAccountAssetsPage(account, chainId, offset, fungible);

if (!data.length) return accum;

Expand All @@ -145,7 +143,7 @@ export function fetchTzktAccountAssets(
return recurse([], 0);
}

const fetchTzktAccountAssetsOnce = (
const fetchTzktAccountAssetsPage = (
account: string,
chainId: TzktApiChainId,
offset?: number,
Expand All @@ -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'
Expand Down
1 change: 0 additions & 1 deletion src/lib/assets/hooks/collectibles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AccountCollectible[]>(
() =>
Expand Down
1 change: 0 additions & 1 deletion src/lib/metadata/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand Down

0 comments on commit 425fad9

Please sign in to comment.