ReFi-Protocol / dashboard

https://dashboard-indol-zeta-98.vercel.app
0 stars 4 forks source link

The number of NFTs don't match #68

Open ReFiProtocol opened 2 months ago

ReFiProtocol commented 2 months ago

Here is my beta test wallet address: GRA8heanknRYQ6d7bCTdfm9eYYJxw8K94wmrhTE3o3cf

image

It says I have 5 NFTs

I only see 4 on my dashboard: image

yato-sketch commented 2 months ago

Understood.

This bug is related to filter logic.

Exactly, this code. `import { fetchAllDigitalAsset } from "@metaplex-foundation/mpl-token-metadata"; import { Umi } from "@metaplex-foundation/umi"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { Stake } from "../staking/types";

export async function getStakedNfts(umi: Umi, stakes: Stake[]) { try { const lockedNfts: any = []; const collectibleNfts: any = [];

    stakes
        .filter(stake => stake.nft !== null && stake.nftLockTime && stake.nftUnlockTime)
        .forEach(stake => {
            if (stake.nftLockTime && stake.nftUnlockTime) {
                const lockTime = (stake.nftLockTime as BN).toNumber();
                const unlockTime = (stake.nftUnlockTime as BN).toNumber();
                console.log(lockTime, unlockTime)

                const lockDurationDays = (unlockTime - lockTime) / (3600 * 24);

                if (lockDurationDays <= stake.maxNftApyDurationDays) {
                    lockedNfts.push(stake.nft as PublicKey);
                } else {
                    collectibleNfts.push(stake.nft as PublicKey);
                }
            }
        });
    if (lockedNfts.length === 0 && collectibleNfts.length === 0) {
        return { lockedNfts: [], collectibleNfts: [] };
    }

    const lockedNftMetadata = lockedNfts.length > 0 ? await fetchAllDigitalAsset(umi, lockedNfts) : [];
    const collectibleNftMetadata = collectibleNfts.length > 0 ? await fetchAllDigitalAsset(umi, collectibleNfts) : [];

    return {
        lockedNfts: lockedNftMetadata,
        collectibleNfts: collectibleNftMetadata
    };
} catch (error) {
    console.error("Error fetching staked NFTs:", error);
    return { lockedNfts: [], collectibleNfts: [] };
}

}`

Will check once again and fix that