Skip to content

Commit

Permalink
fix initial display
Browse files Browse the repository at this point in the history
  • Loading branch information
zapaz committed May 15, 2024
1 parent 8b985ef commit 461f340
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
7 changes: 4 additions & 3 deletions common/src/apis/api-covalent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import config from "@kredeum/config/dist/config.json";

import type { FetchResponse } from "../common/fetch";
import type { CollectionFilterType, CollectionType, NftType } from "../common/types";
import { ADDRESS_ZERO, getChecksumAddress } from "../common/config";
import { ADDRESS_ZERO, getChecksumAddress, isAddressNotZero } from "../common/config";
import { DEFAULT_NAME, DEFAULT_SYMBOL } from "../common/config";
import { fetchJson, FETCH_LIMIT } from "../common/fetch";
import { keyCollection, keyNft } from "../common/keys";
Expand Down Expand Up @@ -36,12 +36,12 @@ const _covalentFetch = async (chainId: number, path: string): Promise<unknown> =
};

const covalentCollections = async (chainId: number, account: string): Promise<Map<string, CollectionType>> => {
// console.log(`covalentCollections ${keyCollection(chainId, account)}\n`);
// console.log(`covalentCollections ${chainId} ${account}\n`);

const collections: Map<string, CollectionType> = new Map();
const chainName = networks.getChainName(chainId);

if (!(chainId && chainName && account)) return collections;
if (!(chainId && chainName && isAddressNotZero(account))) return collections;

// const match =
// eslint-disable-next-line quotes
Expand All @@ -50,6 +50,7 @@ const covalentCollections = async (chainId: number, account: string): Promise<Ma
// `address/${account}/balances_v2/` + "?nft=true" + "&no-nft-fetch=false" + `&match=${encodeURIComponent(match)}`;

const path = `address/${account}/balances_nft/?no-spam=true&no-nft-asset-metadata=true&with-uncached=true`;
// console.log("covalentCollections ~ path:", path);

type CollectionCov = {
contract_name: string;
Expand Down
4 changes: 2 additions & 2 deletions common/src/apis/api-thegraph.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber } from "ethers";

import type { CollectionType, CollectionFilterType, NftType } from "../common/types";
import { ADDRESS_ZERO, getChecksumAddress } from "../common/config";
import { ADDRESS_ZERO, getChecksumAddress, isAddressNotZero } from "../common/config";

import { fetchGQL, FETCH_LIMIT } from "../common/fetch";
import { keyCollection, keyNft } from "../common/keys";
Expand Down Expand Up @@ -71,7 +71,7 @@ const thegraphCollections = async (chainId: number, account: string): Promise<Ma
const collections: Map<string, CollectionType> = new Map();
const network = networks.get(chainId);

if (account) {
if (isAddressNotZero(account)) {
const query = `
{
ownerPerTokenContracts(
Expand Down
6 changes: 1 addition & 5 deletions common/src/collection/collection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const collectionList = async (
account?: string,
mintable?: boolean
): Promise<Map<string, CollectionType>> => {
// console.log(`collectionList ${keyCollections(chainId, account)}\n`);
// console.log(`collectionList ${chainId} ${account}\n`);

let collections: Map<string, CollectionType> = new Map();

Expand All @@ -55,10 +55,6 @@ const collectionList = async (
collectionsApi = await covalentCollections(chainId, account);
// console.log("collectionList covalentCollections", collectionsApi);
}
// else if (infuraActive(chainId)) {
// collectionsApi = await infuraCollections(chainId, account);
// // console.log("collectionList infuraCollections", collectionsApi);
// }

const lengthBefore = collectionsApi.size;
// console.log("collectionsApi BEFORE", collectionsApi);
Expand Down
2 changes: 1 addition & 1 deletion svelte/src/components/Collection/CollectionSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// let i: number = 0;
// HANDLE CHANGE : on truthy chainId and account, and whatever mintable
$: $refreshAll, mintable, chainId && handleChangeCollection();
$: $refreshAll, mintable, account && chainId && handleChangeCollection();
const handleChangeCollection = async (): Promise<void> => {
// console.log(`COLLECTION LIST CHANGE #${i++} ${keyCollection(chainId, account || ADDRESS_ZERO)}`);
Expand Down
2 changes: 1 addition & 1 deletion svelte/src/components/Nft/Nft.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/////////////////////////////////////////////////////////////
$: nft = nftStoreAndRefresh(chainId, address, tokenID);
/////////////////////////////////////////////////////////////
// $: console.log("NFT", $nft);
// $: console.log("<Nft", $nft);
let nftLink = "";
let nftLinkDone = "";
Expand Down
3 changes: 1 addition & 2 deletions svelte/src/components/Nfts/Nfts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@
refreshing = false;
console.info("NFTS", $nfts);
// console.log("NFTS refreshed params", chainId, address, { owner, offset, limit });
console.info("<Nfts", { chainId, address, tokenID, owner, page }, "\n", $nfts);
};
onMount(async () => {
Expand Down
1 change: 1 addition & 0 deletions svelte/src/stores/collection/collectionSubList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const collectionSubListRefresh = async (
address?: string,
mintable = false
): Promise<void> => {
// console.log("collectionSubListRefresh:", chainId, account, address, mintable);
if (!chainId) return;

const colls = await collectionListLib(chainId, account, mintable);
Expand Down

0 comments on commit 461f340

Please sign in to comment.