UNPKG

@cross-nft-marketplace/auction-house-nft-hooks

Version:

Generic react hooks for fetching cross-nft-marketplace auctions, nfts, and data on arbitary 721s. Powers nft-components.

40 lines (39 loc) 1.53 kB
import { NftDataFetchStrategy } from '../hooks/useNFT'; import { NFTDataType } from './AuctionInfoTypes'; import { MediaFetchAgent } from './MediaFetchAgent'; import { MetadataIsh } from './MetadataTypes'; /** * This removes undefined values to sanitize * data objects to work with nextJS server-side * page props. * * @param json Object to sanitize for JSON fields * @returns JSON-safe object */ export declare function prepareJson<T>(json: T): T; declare type fetchNFTDataType = { tokenId: string; contractAddress?: string; fetchAgent: MediaFetchAgent; prepareDataJSON?: boolean; fetchStrategy?: NftDataFetchStrategy; loadAuctionInfo?: boolean; requireData?: boolean; }; /** * Async function to fetch auction information and metadata for any * NFT or zNFT. Mirrors behavior of useNFT hook but for server-side rendering. * Fetches all metadata and auction information server-side. Will be re-validated client-side. * Can pass return value directly into `initialData` for useNFT hook. * * @param tokenId: Token ID to fetch * @param contractAddress: Contract address to fetch token from * @param fetchAgent: MediaFetchAgent instance * @param prepareDataJSON: Sanitizes undefined fields to allow data to work with next.js * @returns object with nft and metadata fields, any issues throw an RequestError */ export declare const fetchNFTData: (args: fetchNFTDataType) => Promise<{ nft: NFTDataType; metadata: MetadataIsh; }>; export {};