import type { TokenMetadata } from '@explorins/pers-sdk';
/**
* React hook for resolving media URLs (IPFS or HTTPS).
*
* Automatically handles IPFS URLs by resolving them to HTTPS via tenant's gateway.
* Non-IPFS URLs are returned as-is. Handles loading and error states.
*
* Uses sdk.tenants for IPFS resolution (lightweight, no Web3 deps).
*
* @param url - The URL to resolve (can be ipfs://, https://, or undefined)
* @returns Object with resolved URL, loading state, and error
*
* @example
* ```tsx
* function NFTImage({ metadataUri }: { metadataUri?: string }) {
* const { url, isLoading } = useResolvedUrl(metadataUri);
*
* if (isLoading) return ;
* return ;
* }
* ```
*/
export declare function useResolvedUrl(url: string | undefined | null): {
/** Resolved HTTPS URL (or original if not IPFS) */
url: string | null;
/** Whether resolution is in progress */
isLoading: boolean;
/** Error message if resolution failed */
error: string | null;
};
/**
* React hook for fetching NFT/token metadata from a URI.
*
* Handles IPFS resolution automatically and returns parsed metadata
* with all nested IPFS URLs already resolved to HTTPS.
*
* Uses sdk.tenants for metadata fetching (lightweight, no Web3 deps).
*
* @param metadataUri - The metadata URI to fetch (can be ipfs:// or https://)
* @returns Object with metadata, loading state, error, and refresh function
*
* @example
* ```tsx
* function NFTDetails({ metadataUri }: { metadataUri?: string }) {
* const { metadata, isLoading, error } = useMetadata(metadataUri);
*
* if (isLoading) return ;
* if (error) return Error: {error};
* if (!metadata) return null;
*
* return (
*
*
* {metadata.name}
* {metadata.description}
*
* );
* }
* ```
*/
export declare function useMetadata(metadataUri: string | undefined | null): {
/** Parsed metadata with resolved IPFS URLs (imageUrl, animationUrl, etc.) */
metadata: TokenMetadata | null;
/** Whether fetch is in progress */
isLoading: boolean;
/** Error message if fetch failed */
error: string | null;
/** Manually refresh metadata */
refresh: () => Promise;
};
export { useResolvedUrl as useIPFSUrl };
/**
* React hook for loading transaction/token metadata.
*
* Convenience wrapper around useMetadata specifically for transaction items.
* Pass a transaction's metadataUri to get the NFT image, name, description, etc.
*
* @param transaction - Transaction object with optional metadataUri field
* @returns Object with metadata, loading state, and image URL
*
* @example
* ```tsx
* import { useTransactionMetadata } from '@explorins/pers-sdk-react-native';
*
* function TransactionItem({ tx }: { tx: TransactionDTO }) {
* const { metadata, isLoading, imageUrl } = useTransactionMetadata(tx);
*
* if (isLoading) return ;
*
* return (
*
* {imageUrl && }
* {metadata?.name || tx.type}
* {tx.amount} tokens
*
* );
* }
* ```
*/
export declare function useTransactionMetadata(transaction: {
metadataUri?: string | null;
} | null | undefined): {
/** Parsed metadata with resolved URLs */
metadata: TokenMetadata | null;
/** Whether metadata is loading */
isLoading: boolean;
/** Error message if fetch failed */
error: string | null;
/** Convenience: resolved image URL (or undefined) */
imageUrl: string | undefined;
/** Convenience: token/NFT name (or undefined) */
name: string | undefined;
/** Convenience: token/NFT description (or undefined) */
description: string | undefined;
/** Manually refresh metadata */
refresh: () => Promise;
};
//# sourceMappingURL=useIPFSUrl.d.ts.map