From baa0bea8219fe8eef236a418f105b3a1b3a3a089 Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Tue, 10 Dec 2024 16:16:17 -0500 Subject: [PATCH 1/9] chore: migrate nft --- .../nft/hooks/useLifecycleStatus.test.ts | 0 .../nft/hooks/useLifecycleStatus.ts | 0 .../nft/hooks/useMintData.test.ts | 2 +- src/{ => core-react}/nft/hooks/useMintData.ts | 4 +- .../nft/hooks/useMintDetails.test.ts | 0 .../nft/hooks/useMintDetails.ts | 6 +- .../nft/hooks/useNFTData.test.ts | 0 src/{ => core-react}/nft/hooks/useNFTData.ts | 4 +- .../nft/hooks/useTokenDetails.test.ts | 0 .../nft/hooks/useTokenDetails.ts | 6 +- .../providers}/NFTLifecycleProvider.test.tsx | 0 .../nft/providers}/NFTLifecycleProvider.tsx | 2 +- .../nft/providers}/NFTProvider.test.tsx | 0 .../nft/providers}/NFTProvider.tsx | 2 +- src/{ => core-react}/nft/types.ts | 2 +- src/core/api/types.ts | 2 +- .../utils/buildMintTransactionData.test.ts | 2 +- .../nft/utils/buildMintTransactionData.ts | 6 +- src/{ => core}/nft/utils/ipfs.test.ts | 0 src/{ => core}/nft/utils/ipfs.ts | 0 src/{ => core}/nft/utils/isNFTError.test.ts | 0 src/{ => core}/nft/utils/isNFTError.ts | 2 +- src/nft/index.ts | 16 --- .../react/nft}/NFTCard.test.tsx | 0 .../components => ui/react/nft}/NFTCard.tsx | 14 +-- .../react/nft}/NFTCardDefault.test.tsx | 0 .../react/nft}/NFTCardDefault.tsx | 2 +- .../react/nft}/NFTErrorBoundary.test.tsx | 0 .../react/nft}/NFTErrorBoundary.tsx | 0 .../react/nft}/NFTErrorFallback.test.tsx | 4 +- .../react/nft}/NFTErrorFallback.tsx | 4 +- .../react/nft}/NFTMintCard.test.tsx | 0 .../react/nft}/NFTMintCard.tsx | 16 +-- .../react/nft}/NFTMintCardDefault.test.tsx | 0 .../react/nft}/NFTMintCardDefault.tsx | 2 +- src/ui/react/nft/components/view/NFTAudio.tsx | 105 ++++++++++++++++++ src/ui/react/nft/components/view/NFTImage.tsx | 97 ++++++++++++++++ src/ui/react/nft/components/view/NFTVideo.tsx | 74 ++++++++++++ src/ui/react/nft/index.ts | 16 +++ .../react/nft}/mint/NFTAssetCost.test.tsx | 0 .../react/nft}/mint/NFTAssetCost.tsx | 10 +- .../nft}/mint/NFTCollectionTitle.test.tsx | 0 .../react/nft}/mint/NFTCollectionTitle.tsx | 4 +- .../react/nft}/mint/NFTCreator.test.tsx | 0 .../react/nft}/mint/NFTCreator.tsx | 8 +- .../react/nft}/mint/NFTMintButton.test.tsx | 0 .../react/nft}/mint/NFTMintButton.tsx | 14 +-- .../react/nft}/mint/NFTMinters.test.tsx | 0 .../react/nft}/mint/NFTMinters.tsx | 8 +- .../nft}/mint/NFTQuantitySelector.test.tsx | 0 .../react/nft}/mint/NFTQuantitySelector.tsx | 6 +- .../react/nft}/mint/NFTTotalCost.test.tsx | 0 .../react/nft}/mint/NFTTotalCost.tsx | 10 +- .../components => ui/react/nft}/mint/index.ts | 0 .../react/nft}/view/NFTAudio.test.tsx | 0 .../react/nft}/view/NFTAudio.tsx | 6 +- .../react/nft}/view/NFTImage.test.tsx | 0 .../react/nft}/view/NFTImage.tsx | 8 +- .../react/nft}/view/NFTLastSoldPrice.test.tsx | 0 .../react/nft}/view/NFTLastSoldPrice.tsx | 8 +- .../react/nft}/view/NFTMedia.test.tsx | 0 .../react/nft}/view/NFTMedia.tsx | 4 +- .../react/nft}/view/NFTMintDate.test.tsx | 0 .../react/nft}/view/NFTMintDate.tsx | 4 +- .../react/nft}/view/NFTNetwork.test.tsx | 0 .../react/nft}/view/NFTNetwork.tsx | 4 +- .../react/nft}/view/NFTOwner.test.tsx | 0 .../react/nft}/view/NFTOwner.tsx | 8 +- .../react/nft}/view/NFTTitle.test.tsx | 0 .../react/nft}/view/NFTTitle.tsx | 4 +- .../react/nft}/view/NFTVideo.test.tsx | 4 +- .../react/nft}/view/NFTVideo.tsx | 8 +- .../components => ui/react/nft}/view/index.ts | 0 73 files changed, 392 insertions(+), 116 deletions(-) rename src/{ => core-react}/nft/hooks/useLifecycleStatus.test.ts (100%) rename src/{ => core-react}/nft/hooks/useLifecycleStatus.ts (100%) rename src/{ => core-react}/nft/hooks/useMintData.test.ts (97%) rename src/{ => core-react}/nft/hooks/useMintData.ts (91%) rename src/{ => core-react}/nft/hooks/useMintDetails.test.ts (100%) rename src/{ => core-react}/nft/hooks/useMintDetails.ts (75%) rename src/{ => core-react}/nft/hooks/useNFTData.test.ts (100%) rename src/{ => core-react}/nft/hooks/useNFTData.ts (90%) rename src/{ => core-react}/nft/hooks/useTokenDetails.test.ts (100%) rename src/{ => core-react}/nft/hooks/useTokenDetails.ts (81%) rename src/{nft/components => core-react/nft/providers}/NFTLifecycleProvider.test.tsx (100%) rename src/{nft/components => core-react/nft/providers}/NFTLifecycleProvider.tsx (96%) rename src/{nft/components => core-react/nft/providers}/NFTProvider.test.tsx (100%) rename src/{nft/components => core-react/nft/providers}/NFTProvider.tsx (94%) rename src/{ => core-react}/nft/types.ts (99%) rename src/{ => core}/nft/utils/buildMintTransactionData.test.ts (97%) rename src/{ => core}/nft/utils/buildMintTransactionData.ts (85%) rename src/{ => core}/nft/utils/ipfs.test.ts (100%) rename src/{ => core}/nft/utils/ipfs.ts (100%) rename src/{ => core}/nft/utils/isNFTError.test.ts (100%) rename src/{ => core}/nft/utils/isNFTError.ts (72%) delete mode 100644 src/nft/index.ts rename src/{nft/components => ui/react/nft}/NFTCard.test.tsx (100%) rename src/{nft/components => ui/react/nft}/NFTCard.tsx (75%) rename src/{nft/components => ui/react/nft}/NFTCardDefault.test.tsx (100%) rename src/{nft/components => ui/react/nft}/NFTCardDefault.tsx (89%) rename src/{nft/components => ui/react/nft}/NFTErrorBoundary.test.tsx (100%) rename src/{nft/components => ui/react/nft}/NFTErrorBoundary.tsx (100%) rename src/{nft/components => ui/react/nft}/NFTErrorFallback.test.tsx (83%) rename src/{nft/components => ui/react/nft}/NFTErrorFallback.tsx (78%) rename src/{nft/components => ui/react/nft}/NFTMintCard.test.tsx (100%) rename src/{nft/components => ui/react/nft}/NFTMintCard.tsx (70%) rename src/{nft/components => ui/react/nft}/NFTMintCardDefault.test.tsx (100%) rename src/{nft/components => ui/react/nft}/NFTMintCardDefault.tsx (91%) create mode 100644 src/ui/react/nft/components/view/NFTAudio.tsx create mode 100644 src/ui/react/nft/components/view/NFTImage.tsx create mode 100644 src/ui/react/nft/components/view/NFTVideo.tsx create mode 100644 src/ui/react/nft/index.ts rename src/{nft/components => ui/react/nft}/mint/NFTAssetCost.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTAssetCost.tsx (71%) rename src/{nft/components => ui/react/nft}/mint/NFTCollectionTitle.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTCollectionTitle.tsx (71%) rename src/{nft/components => ui/react/nft}/mint/NFTCreator.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTCreator.tsx (68%) rename src/{nft/components => ui/react/nft}/mint/NFTMintButton.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTMintButton.tsx (90%) rename src/{nft/components => ui/react/nft}/mint/NFTMinters.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTMinters.tsx (81%) rename src/{nft/components => ui/react/nft}/mint/NFTQuantitySelector.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTQuantitySelector.tsx (72%) rename src/{nft/components => ui/react/nft}/mint/NFTTotalCost.test.tsx (100%) rename src/{nft/components => ui/react/nft}/mint/NFTTotalCost.tsx (90%) rename src/{nft/components => ui/react/nft}/mint/index.ts (100%) rename src/{nft/components => ui/react/nft}/view/NFTAudio.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTAudio.tsx (92%) rename src/{nft/components => ui/react/nft}/view/NFTImage.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTImage.tsx (89%) rename src/{nft/components => ui/react/nft}/view/NFTLastSoldPrice.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTLastSoldPrice.tsx (76%) rename src/{nft/components => ui/react/nft}/view/NFTMedia.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTMedia.tsx (94%) rename src/{nft/components => ui/react/nft}/view/NFTMintDate.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTMintDate.tsx (86%) rename src/{nft/components => ui/react/nft}/view/NFTNetwork.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTNetwork.tsx (88%) rename src/{nft/components => ui/react/nft}/view/NFTOwner.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTOwner.tsx (74%) rename src/{nft/components => ui/react/nft}/view/NFTTitle.test.tsx (100%) rename src/{nft/components => ui/react/nft}/view/NFTTitle.tsx (70%) rename src/{nft/components => ui/react/nft}/view/NFTVideo.test.tsx (94%) rename src/{nft/components => ui/react/nft}/view/NFTVideo.tsx (86%) rename src/{nft/components => ui/react/nft}/view/index.ts (100%) diff --git a/src/nft/hooks/useLifecycleStatus.test.ts b/src/core-react/nft/hooks/useLifecycleStatus.test.ts similarity index 100% rename from src/nft/hooks/useLifecycleStatus.test.ts rename to src/core-react/nft/hooks/useLifecycleStatus.test.ts diff --git a/src/nft/hooks/useLifecycleStatus.ts b/src/core-react/nft/hooks/useLifecycleStatus.ts similarity index 100% rename from src/nft/hooks/useLifecycleStatus.ts rename to src/core-react/nft/hooks/useLifecycleStatus.ts diff --git a/src/nft/hooks/useMintData.test.ts b/src/core-react/nft/hooks/useMintData.test.ts similarity index 97% rename from src/nft/hooks/useMintData.test.ts rename to src/core-react/nft/hooks/useMintData.test.ts index b2cf08b47e..e5d9fac766 100644 --- a/src/nft/hooks/useMintData.test.ts +++ b/src/core-react/nft/hooks/useMintData.test.ts @@ -9,7 +9,7 @@ import { vi, } from 'vitest'; import { useAccount } from 'wagmi'; -import { useNFTLifecycleContext } from '../components/NFTLifecycleProvider'; +import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import { useMintData } from './useMintData'; import { useMintDetails } from './useMintDetails'; diff --git a/src/nft/hooks/useMintData.ts b/src/core-react/nft/hooks/useMintData.ts similarity index 91% rename from src/nft/hooks/useMintData.ts rename to src/core-react/nft/hooks/useMintData.ts index 9e6a89b6c2..e98e66ef1e 100644 --- a/src/nft/hooks/useMintData.ts +++ b/src/core-react/nft/hooks/useMintData.ts @@ -1,8 +1,8 @@ import { useEffect, useState } from 'react'; import { useAccount } from 'wagmi'; -import { useNFTLifecycleContext } from '../components/NFTLifecycleProvider'; +import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import type { NFTData, NFTError } from '../types'; -import { convertIpfsToHttps } from '../utils/ipfs'; +import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useMintDetails } from './useMintDetails'; export function useMintData( diff --git a/src/nft/hooks/useMintDetails.test.ts b/src/core-react/nft/hooks/useMintDetails.test.ts similarity index 100% rename from src/nft/hooks/useMintDetails.test.ts rename to src/core-react/nft/hooks/useMintDetails.test.ts diff --git a/src/nft/hooks/useMintDetails.ts b/src/core-react/nft/hooks/useMintDetails.ts similarity index 75% rename from src/nft/hooks/useMintDetails.ts rename to src/core-react/nft/hooks/useMintDetails.ts index 9bbc48f594..1da10b2cd8 100644 --- a/src/nft/hooks/useMintDetails.ts +++ b/src/core-react/nft/hooks/useMintDetails.ts @@ -1,7 +1,7 @@ import { type UseQueryResult, useQuery } from '@tanstack/react-query'; -import { getMintDetails } from '../../core/api/getMintDetails'; -import type { GetMintDetailsParams, MintDetails } from '../../core/api/types'; -import { isNFTError } from '../utils/isNFTError'; +import { getMintDetails } from '../../../core/api/getMintDetails'; +import type { GetMintDetailsParams, MintDetails } from '../../../core/api/types'; +import { isNFTError } from '../../../core/nft/utils/isNFTError'; export function useMintDetails({ contractAddress, diff --git a/src/nft/hooks/useNFTData.test.ts b/src/core-react/nft/hooks/useNFTData.test.ts similarity index 100% rename from src/nft/hooks/useNFTData.test.ts rename to src/core-react/nft/hooks/useNFTData.test.ts diff --git a/src/nft/hooks/useNFTData.ts b/src/core-react/nft/hooks/useNFTData.ts similarity index 90% rename from src/nft/hooks/useNFTData.ts rename to src/core-react/nft/hooks/useNFTData.ts index 27af8cc6ae..33bc46bbb6 100644 --- a/src/nft/hooks/useNFTData.ts +++ b/src/core-react/nft/hooks/useNFTData.ts @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; -import { useNFTLifecycleContext } from '../components/NFTLifecycleProvider'; +import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import type { ContractType, NFTData, NFTError } from '../types'; -import { convertIpfsToHttps } from '../utils/ipfs'; +import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useTokenDetails } from './useTokenDetails'; export function useNFTData( diff --git a/src/nft/hooks/useTokenDetails.test.ts b/src/core-react/nft/hooks/useTokenDetails.test.ts similarity index 100% rename from src/nft/hooks/useTokenDetails.test.ts rename to src/core-react/nft/hooks/useTokenDetails.test.ts diff --git a/src/nft/hooks/useTokenDetails.ts b/src/core-react/nft/hooks/useTokenDetails.ts similarity index 81% rename from src/nft/hooks/useTokenDetails.ts rename to src/core-react/nft/hooks/useTokenDetails.ts index 383ad10c8c..3df2220b99 100644 --- a/src/nft/hooks/useTokenDetails.ts +++ b/src/core-react/nft/hooks/useTokenDetails.ts @@ -1,7 +1,7 @@ import { type UseQueryResult, useQuery } from '@tanstack/react-query'; -import { getTokenDetails } from '../../core/api/getTokenDetails'; -import type { GetTokenDetailsParams, TokenDetails } from '../../core/api/types'; -import { isNFTError } from '../utils/isNFTError'; +import { getTokenDetails } from '../../../core/api/getTokenDetails'; +import type { GetTokenDetailsParams, TokenDetails } from '../../../core/api/types'; +import { isNFTError } from '../../../core/nft/utils/isNFTError'; export function useTokenDetails({ contractAddress, diff --git a/src/nft/components/NFTLifecycleProvider.test.tsx b/src/core-react/nft/providers/NFTLifecycleProvider.test.tsx similarity index 100% rename from src/nft/components/NFTLifecycleProvider.test.tsx rename to src/core-react/nft/providers/NFTLifecycleProvider.test.tsx diff --git a/src/nft/components/NFTLifecycleProvider.tsx b/src/core-react/nft/providers/NFTLifecycleProvider.tsx similarity index 96% rename from src/nft/components/NFTLifecycleProvider.tsx rename to src/core-react/nft/providers/NFTLifecycleProvider.tsx index e6f3793990..b02a57bb54 100644 --- a/src/nft/components/NFTLifecycleProvider.tsx +++ b/src/core-react/nft/providers/NFTLifecycleProvider.tsx @@ -1,5 +1,5 @@ import { createContext, useContext, useEffect } from 'react'; -import { useValue } from '../../core-react/internal/hooks/useValue'; +import { useValue } from '../../internal/hooks/useValue'; import { useLifecycleStatus } from '../hooks/useLifecycleStatus'; import type { NFTLifecycleContextType, diff --git a/src/nft/components/NFTProvider.test.tsx b/src/core-react/nft/providers/NFTProvider.test.tsx similarity index 100% rename from src/nft/components/NFTProvider.test.tsx rename to src/core-react/nft/providers/NFTProvider.test.tsx diff --git a/src/nft/components/NFTProvider.tsx b/src/core-react/nft/providers/NFTProvider.tsx similarity index 94% rename from src/nft/components/NFTProvider.tsx rename to src/core-react/nft/providers/NFTProvider.tsx index c09465a4aa..eda877f14b 100644 --- a/src/nft/components/NFTProvider.tsx +++ b/src/core-react/nft/providers/NFTProvider.tsx @@ -1,5 +1,5 @@ import { createContext, useCallback, useContext, useState } from 'react'; -import { useValue } from '../../core-react/internal/hooks/useValue'; +import { useValue } from '../../internal/hooks/useValue'; import type { NFTContextType, NFTProviderReact } from '../types'; const emptyContext = {} as NFTContextType; diff --git a/src/nft/types.ts b/src/core-react/nft/types.ts similarity index 99% rename from src/nft/types.ts rename to src/core-react/nft/types.ts index 3d7ae6b06b..f6c8edbbc5 100644 --- a/src/nft/types.ts +++ b/src/core-react/nft/types.ts @@ -1,6 +1,6 @@ import type { ReactNode } from 'react'; import type { Address, Hex, TransactionReceipt } from 'viem'; -import type { Call, TransactionError } from '../transaction/types'; +import type { Call, TransactionError } from '../../transaction/types'; export type ContractType = 'ERC721' | 'ERC1155'; diff --git a/src/core/api/types.ts b/src/core/api/types.ts index 59277133dc..7facf00239 100644 --- a/src/core/api/types.ts +++ b/src/core/api/types.ts @@ -1,5 +1,5 @@ import type { Address } from 'viem'; -import type { ContractType, NFTPrice } from '../../nft/types'; +import type { ContractType, NFTPrice } from '../../core-react/nft/types'; import type { Fee, QuoteWarning, diff --git a/src/nft/utils/buildMintTransactionData.test.ts b/src/core/nft/utils/buildMintTransactionData.test.ts similarity index 97% rename from src/nft/utils/buildMintTransactionData.test.ts rename to src/core/nft/utils/buildMintTransactionData.test.ts index 0917712945..d6c036f9f1 100644 --- a/src/nft/utils/buildMintTransactionData.test.ts +++ b/src/core/nft/utils/buildMintTransactionData.test.ts @@ -1,6 +1,6 @@ import type { Address } from 'viem'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { buildMintTransaction as buildMintTransationApi } from '../../core/api/buildMintTransaction'; +import { buildMintTransaction as buildMintTransationApi } from '../../api/buildMintTransaction'; import { buildMintTransactionData } from './buildMintTransactionData'; vi.mock('../../core/api/buildMintTransaction'); diff --git a/src/nft/utils/buildMintTransactionData.ts b/src/core/nft/utils/buildMintTransactionData.ts similarity index 85% rename from src/nft/utils/buildMintTransactionData.ts rename to src/core/nft/utils/buildMintTransactionData.ts index 20409d42a0..bec600e14d 100644 --- a/src/nft/utils/buildMintTransactionData.ts +++ b/src/core/nft/utils/buildMintTransactionData.ts @@ -1,7 +1,7 @@ import type { Address } from 'viem'; -import { buildMintTransaction as buildMintTransactionApi } from '../../core/api/buildMintTransaction'; -import type { BuildMintTransactionParams } from '../../core/api/types'; -import type { Call } from '../../transaction/types'; +import { buildMintTransaction as buildMintTransactionApi } from '../../api/buildMintTransaction'; +import type { BuildMintTransactionParams } from '../../api/types'; +import type { Call } from '../../../transaction/types'; async function getMintTransaction({ mintAddress, diff --git a/src/nft/utils/ipfs.test.ts b/src/core/nft/utils/ipfs.test.ts similarity index 100% rename from src/nft/utils/ipfs.test.ts rename to src/core/nft/utils/ipfs.test.ts diff --git a/src/nft/utils/ipfs.ts b/src/core/nft/utils/ipfs.ts similarity index 100% rename from src/nft/utils/ipfs.ts rename to src/core/nft/utils/ipfs.ts diff --git a/src/nft/utils/isNFTError.test.ts b/src/core/nft/utils/isNFTError.test.ts similarity index 100% rename from src/nft/utils/isNFTError.test.ts rename to src/core/nft/utils/isNFTError.test.ts diff --git a/src/nft/utils/isNFTError.ts b/src/core/nft/utils/isNFTError.ts similarity index 72% rename from src/nft/utils/isNFTError.ts rename to src/core/nft/utils/isNFTError.ts index 1d1353365a..5e6937aafa 100644 --- a/src/nft/utils/isNFTError.ts +++ b/src/core/nft/utils/isNFTError.ts @@ -1,4 +1,4 @@ -import type { NFTError } from '../types'; +import type { NFTError } from '../../../core-react/nft/types'; export function isNFTError(response: unknown): response is NFTError { return ( diff --git a/src/nft/index.ts b/src/nft/index.ts deleted file mode 100644 index 4a66cecc08..0000000000 --- a/src/nft/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export { NFTMintCard } from './components/NFTMintCard'; -export { NFTMintCardDefault } from './components/NFTMintCardDefault'; -export { NFTCard } from './components/NFTCard'; -export { NFTCardDefault } from './components/NFTCardDefault'; - -export type { - BuildMintTransaction, - LifecycleStatus, - NFTCardReact, - NFTCardDefaultReact, - NFTData, - NFTError, - NFTMintCardReact, - NFTMintCardDefaultReact, - UseNFTData, -} from './types'; diff --git a/src/nft/components/NFTCard.test.tsx b/src/ui/react/nft/NFTCard.test.tsx similarity index 100% rename from src/nft/components/NFTCard.test.tsx rename to src/ui/react/nft/NFTCard.test.tsx diff --git a/src/nft/components/NFTCard.tsx b/src/ui/react/nft/NFTCard.tsx similarity index 75% rename from src/nft/components/NFTCard.tsx rename to src/ui/react/nft/NFTCard.tsx index bdd4498c78..86f4a13c30 100644 --- a/src/nft/components/NFTCard.tsx +++ b/src/ui/react/nft/NFTCard.tsx @@ -1,14 +1,14 @@ import { useCallback } from 'react'; import { useAccount } from 'wagmi'; -import { useIsMounted } from '../../core-react/internal/hooks/useIsMounted'; -import { useTheme } from '../../core-react/internal/hooks/useTheme'; -import { border, cn, color, pressable } from '../../styles/theme'; -import { useNFTData as defaultUseNFTData } from '../hooks/useNFTData'; -import { LifecycleType, type NFTCardReact } from '../types'; +import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; +import { useTheme } from '../../../core-react/internal/hooks/useTheme'; +import { border, cn, color, pressable } from '../../../styles/theme'; +import { useNFTData as defaultUseNFTData } from '../../../core-react/nft/hooks/useNFTData'; +import { LifecycleType, type NFTCardReact } from '../../../core-react/nft/types'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; -import { NFTLifecycleProvider } from './NFTLifecycleProvider'; -import { NFTProvider } from './NFTProvider'; +import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; export function NFTCard({ children, diff --git a/src/nft/components/NFTCardDefault.test.tsx b/src/ui/react/nft/NFTCardDefault.test.tsx similarity index 100% rename from src/nft/components/NFTCardDefault.test.tsx rename to src/ui/react/nft/NFTCardDefault.test.tsx diff --git a/src/nft/components/NFTCardDefault.tsx b/src/ui/react/nft/NFTCardDefault.tsx similarity index 89% rename from src/nft/components/NFTCardDefault.tsx rename to src/ui/react/nft/NFTCardDefault.tsx index c224d9c502..b44f8787d2 100644 --- a/src/nft/components/NFTCardDefault.tsx +++ b/src/ui/react/nft/NFTCardDefault.tsx @@ -1,4 +1,4 @@ -import type { NFTCardDefaultReact } from '../types'; +import type { NFTCardDefaultReact } from '../../../core-react/nft/types'; import { NFTCard } from './NFTCard'; import { NFTLastSoldPrice, diff --git a/src/nft/components/NFTErrorBoundary.test.tsx b/src/ui/react/nft/NFTErrorBoundary.test.tsx similarity index 100% rename from src/nft/components/NFTErrorBoundary.test.tsx rename to src/ui/react/nft/NFTErrorBoundary.test.tsx diff --git a/src/nft/components/NFTErrorBoundary.tsx b/src/ui/react/nft/NFTErrorBoundary.tsx similarity index 100% rename from src/nft/components/NFTErrorBoundary.tsx rename to src/ui/react/nft/NFTErrorBoundary.tsx diff --git a/src/nft/components/NFTErrorFallback.test.tsx b/src/ui/react/nft/NFTErrorFallback.test.tsx similarity index 83% rename from src/nft/components/NFTErrorFallback.test.tsx rename to src/ui/react/nft/NFTErrorFallback.test.tsx index 14efd9dcab..fe5449d330 100644 --- a/src/nft/components/NFTErrorFallback.test.tsx +++ b/src/ui/react/nft/NFTErrorFallback.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useTheme } from '../../core-react/internal/hooks/useTheme'; +import { useTheme } from '../../../core-react/internal/hooks/useTheme'; import { NFTErrorFallback } from './NFTErrorFallback'; -vi.mock('../../core-react/internal/hooks/useTheme'); +vi.mock('../../../core-react/internal/hooks/useTheme'); describe('NFTErrorFallback', () => { beforeEach(() => { diff --git a/src/nft/components/NFTErrorFallback.tsx b/src/ui/react/nft/NFTErrorFallback.tsx similarity index 78% rename from src/nft/components/NFTErrorFallback.tsx rename to src/ui/react/nft/NFTErrorFallback.tsx index 818391857a..d3df65efd2 100644 --- a/src/nft/components/NFTErrorFallback.tsx +++ b/src/ui/react/nft/NFTErrorFallback.tsx @@ -1,5 +1,5 @@ -import { useTheme } from '../../core-react/internal/hooks/useTheme'; -import { background, border, cn, color } from '../../styles/theme'; +import { useTheme } from '../../../core-react/internal/hooks/useTheme'; +import { background, border, cn, color } from '../../../styles/theme'; export function NFTErrorFallback({ error }: { error: Error }) { const componentTheme = useTheme(); diff --git a/src/nft/components/NFTMintCard.test.tsx b/src/ui/react/nft/NFTMintCard.test.tsx similarity index 100% rename from src/nft/components/NFTMintCard.test.tsx rename to src/ui/react/nft/NFTMintCard.test.tsx diff --git a/src/nft/components/NFTMintCard.tsx b/src/ui/react/nft/NFTMintCard.tsx similarity index 70% rename from src/nft/components/NFTMintCard.tsx rename to src/ui/react/nft/NFTMintCard.tsx index 71cf7982b6..70fab1dbd2 100644 --- a/src/nft/components/NFTMintCard.tsx +++ b/src/ui/react/nft/NFTMintCard.tsx @@ -1,13 +1,13 @@ -import { useIsMounted } from '../../core-react/internal/hooks/useIsMounted'; -import { useTheme } from '../../core-react/internal/hooks/useTheme'; -import { background, border, cn, color } from '../../styles/theme'; -import { useMintData as defaultUseMintData } from '../hooks/useMintData'; -import { LifecycleType, type NFTMintCardReact } from '../types'; -import { buildMintTransactionData as defaultBuildMintTransaction } from '../utils/buildMintTransactionData'; +import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; +import { useTheme } from '../../../core-react/internal/hooks/useTheme'; +import { background, border, cn, color } from '../../../styles/theme'; +import { useMintData as defaultUseMintData } from '../../../core-react/nft/hooks/useMintData'; +import { LifecycleType, type NFTMintCardReact } from '../../../core-react/nft/types'; +import { buildMintTransactionData as defaultBuildMintTransaction } from '../../../core/nft/utils/buildMintTransactionData'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; -import { NFTLifecycleProvider } from './NFTLifecycleProvider'; -import { NFTProvider } from './NFTProvider'; +import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; export function NFTMintCard({ children, diff --git a/src/nft/components/NFTMintCardDefault.test.tsx b/src/ui/react/nft/NFTMintCardDefault.test.tsx similarity index 100% rename from src/nft/components/NFTMintCardDefault.test.tsx rename to src/ui/react/nft/NFTMintCardDefault.test.tsx diff --git a/src/nft/components/NFTMintCardDefault.tsx b/src/ui/react/nft/NFTMintCardDefault.tsx similarity index 91% rename from src/nft/components/NFTMintCardDefault.tsx rename to src/ui/react/nft/NFTMintCardDefault.tsx index fd8ad35199..74ecc139f3 100644 --- a/src/nft/components/NFTMintCardDefault.tsx +++ b/src/ui/react/nft/NFTMintCardDefault.tsx @@ -1,4 +1,4 @@ -import type { NFTMintCardDefaultReact } from '../types'; +import type { NFTMintCardDefaultReact } from '../../../core-react/nft/types'; import { NFTMintCard } from './NFTMintCard'; import { NFTAssetCost, diff --git a/src/ui/react/nft/components/view/NFTAudio.tsx b/src/ui/react/nft/components/view/NFTAudio.tsx new file mode 100644 index 0000000000..c9c8fcffbc --- /dev/null +++ b/src/ui/react/nft/components/view/NFTAudio.tsx @@ -0,0 +1,105 @@ +import { + type MouseEvent, + useCallback, + useEffect, + useRef, + useState, +} from 'react'; +import { background, cn } from '../../../../../styles/theme'; +import type { NFTError } from '../../../../../core-react/nft/types'; +import { useNFTContext } from '../../../../../core-react/nft/providers/NFTProvider'; + +type NFTAudioReact = { + className?: string; + onLoading?: (mediaUrl: string) => void; + onLoaded?: () => void; + onError?: (error: NFTError) => void; +}; + +export function NFTAudio({ + className, + onLoading, + onLoaded, + onError, +}: NFTAudioReact) { + const { animationUrl } = useNFTContext(); + const audioRef = useRef(null); + const [isPlaying, setIsPlaying] = useState(false); + + useEffect(() => { + function onEnded() { + setIsPlaying(false); + } + + if (animationUrl && audioRef?.current) { + audioRef.current.onloadstart = () => { + onLoading?.(animationUrl); + }; + + audioRef.current.onloadeddata = () => { + onLoaded?.(); + }; + + audioRef.current.addEventListener('ended', onEnded); + + audioRef.current.onerror = (error: string | Event) => { + onError?.({ + error: typeof error === 'string' ? error : error.type, + code: 'NmNAc01', // NFT module NFTAudio component 01 error + message: 'Error loading audio', + }); + }; + } + }, [animationUrl, onLoading, onLoaded, onError]); + + const handlePlayPause = useCallback( + (event: MouseEvent) => { + event.stopPropagation(); + if (isPlaying) { + audioRef.current?.pause(); + setIsPlaying(false); + } else { + audioRef.current?.play(); + setIsPlaying(true); + } + }, + [isPlaying], + ); + + if (!animationUrl) { + return null; + } + + return ( +
+ + +
+ ); +} diff --git a/src/ui/react/nft/components/view/NFTImage.tsx b/src/ui/react/nft/components/view/NFTImage.tsx new file mode 100644 index 0000000000..dd76c71ea8 --- /dev/null +++ b/src/ui/react/nft/components/view/NFTImage.tsx @@ -0,0 +1,97 @@ +import { type MouseEvent, useCallback, useEffect, useState } from 'react'; +import { defaultNFTSvg } from '../../../../../internal/svg/defaultNFTSvg'; +import { cn } from '../../../../../styles/theme'; +import type { NFTError } from '../../../../../core-react/nft/types'; +import { useNFTContext } from '../../../../../core-react/nft/providers/NFTProvider'; + +type NFTImageReact = { + className?: string; + square?: boolean; + onLoading?: (mediaUrl: string) => void; + onLoaded?: () => void; + onError?: (error: NFTError) => void; +}; + +export function NFTImage({ + className, + square = true, + onLoading, + onLoaded, + onError, +}: NFTImageReact) { + const { imageUrl, description } = useNFTContext(); + const [loaded, setLoaded] = useState(false); + const [error, setError] = useState(false); + + const loadImage = useCallback(() => { + if (imageUrl) { + onLoading?.(imageUrl); + + const img = new Image(); + img.onload = () => { + setLoaded(true); + onLoaded?.(); + }; + + img.onerror = (error: string | Event) => { + onError?.({ + error: typeof error === 'string' ? error : error.type, + code: 'NmNIc01', // NFT module NFTImage component 01 error + message: 'Error loading image', + }); + setError(true); + }; + img.src = imageUrl; + } + }, [imageUrl, onLoading, onLoaded, onError]); + + useEffect(() => { + loadImage(); + }, [loadImage]); + + const handleRetry = useCallback( + async (e: MouseEvent) => { + e.stopPropagation(); + setError(false); + loadImage(); + }, + [loadImage], + ); + + return ( +
*]:col-start-1 [&>*]:col-end-1 [&>*]:row-start-1 [&>*]:row-end-1', + className, + )} + > +
{defaultNFTSvg}
+
+ {description} +
+ {error && ( +
+ +
+ )} +
+ ); +} diff --git a/src/ui/react/nft/components/view/NFTVideo.tsx b/src/ui/react/nft/components/view/NFTVideo.tsx new file mode 100644 index 0000000000..a2ffcd319d --- /dev/null +++ b/src/ui/react/nft/components/view/NFTVideo.tsx @@ -0,0 +1,74 @@ +import { useEffect, useRef } from 'react'; +import { defaultNFTSvg } from '../../../../../internal/svg/defaultNFTSvg'; +import { cn } from '../../../../../styles/theme'; +import type { NFTError } from '../../../../../core-react/nft/types'; +import { useNFTContext } from '../../../../../core-react/nft/providers/NFTProvider'; + +type NFTVideoReact = { + className?: string; + square?: boolean; + onLoading?: (mediaUrl: string) => void; + onLoaded?: () => void; + onError?: (error: NFTError) => void; +}; + +export function NFTVideo({ + className, + square = true, + onLoading, + onLoaded, + onError, +}: NFTVideoReact) { + const { animationUrl, imageUrl } = useNFTContext(); + const videoRef = useRef(null); + + useEffect(() => { + if (animationUrl && videoRef?.current) { + videoRef.current.onloadstart = () => { + onLoading?.(animationUrl); + }; + + videoRef.current.onloadeddata = () => { + onLoaded?.(); + }; + + videoRef.current.onerror = (error: string | Event) => { + onError?.({ + error: typeof error === 'string' ? error : error.type, + code: 'NmNVc01', // NFT module NFTVideo component 01 error + message: 'Error loading video', + }); + }; + } + }, [animationUrl, onLoading, onLoaded, onError]); + + if (!animationUrl) { + return
{defaultNFTSvg}
; + } + + return ( +
*]:col-start-1 [&>*]:col-end-1 [&>*]:row-start-1 [&>*]:row-end-1', + { 'content-center justify-center': !square }, + className, + )} + > +
+ ); +} diff --git a/src/ui/react/nft/index.ts b/src/ui/react/nft/index.ts new file mode 100644 index 0000000000..55407eaad5 --- /dev/null +++ b/src/ui/react/nft/index.ts @@ -0,0 +1,16 @@ +export { NFTMintCard } from './NFTMintCard'; +export { NFTMintCardDefault } from './NFTMintCardDefault'; +export { NFTCard } from './NFTCard'; +export { NFTCardDefault } from './NFTCardDefault'; + +export type { + BuildMintTransaction, + LifecycleStatus, + NFTCardReact, + NFTCardDefaultReact, + NFTData, + NFTError, + NFTMintCardReact, + NFTMintCardDefaultReact, + UseNFTData, +} from '../../../core-react/nft/types'; diff --git a/src/nft/components/mint/NFTAssetCost.test.tsx b/src/ui/react/nft/mint/NFTAssetCost.test.tsx similarity index 100% rename from src/nft/components/mint/NFTAssetCost.test.tsx rename to src/ui/react/nft/mint/NFTAssetCost.test.tsx diff --git a/src/nft/components/mint/NFTAssetCost.tsx b/src/ui/react/nft/mint/NFTAssetCost.tsx similarity index 71% rename from src/nft/components/mint/NFTAssetCost.tsx rename to src/ui/react/nft/mint/NFTAssetCost.tsx index 561b0c0ac7..59a021b1a6 100644 --- a/src/nft/components/mint/NFTAssetCost.tsx +++ b/src/ui/react/nft/mint/NFTAssetCost.tsx @@ -1,8 +1,8 @@ -import { multiplyFloats } from '../../../core/utils/multiplyFloats'; -import { cn, text } from '../../../styles/theme'; -import { formatAmount as formatSN } from '../../../swap/utils/formatAmount'; -import { formatAmount } from '../../../token/utils/formatAmount'; -import { useNFTContext } from '../NFTProvider'; +import { multiplyFloats } from '../../../../core/utils/multiplyFloats'; +import { cn, text } from '../../../../styles/theme'; +import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; +import { formatAmount } from '../../../../token/utils/formatAmount'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTAssetCostReact = { className?: string; diff --git a/src/nft/components/mint/NFTCollectionTitle.test.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx similarity index 100% rename from src/nft/components/mint/NFTCollectionTitle.test.tsx rename to src/ui/react/nft/mint/NFTCollectionTitle.test.tsx diff --git a/src/nft/components/mint/NFTCollectionTitle.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.tsx similarity index 71% rename from src/nft/components/mint/NFTCollectionTitle.tsx rename to src/ui/react/nft/mint/NFTCollectionTitle.tsx index cee6387c6a..4a1a3c087f 100644 --- a/src/nft/components/mint/NFTCollectionTitle.tsx +++ b/src/ui/react/nft/mint/NFTCollectionTitle.tsx @@ -1,5 +1,5 @@ -import { cn, text } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { cn, text } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTCollectionTitleReact = { className?: string; diff --git a/src/nft/components/mint/NFTCreator.test.tsx b/src/ui/react/nft/mint/NFTCreator.test.tsx similarity index 100% rename from src/nft/components/mint/NFTCreator.test.tsx rename to src/ui/react/nft/mint/NFTCreator.test.tsx diff --git a/src/nft/components/mint/NFTCreator.tsx b/src/ui/react/nft/mint/NFTCreator.tsx similarity index 68% rename from src/nft/components/mint/NFTCreator.tsx rename to src/ui/react/nft/mint/NFTCreator.tsx index bd8c2c78c3..d4d4b2d8fe 100644 --- a/src/nft/components/mint/NFTCreator.tsx +++ b/src/ui/react/nft/mint/NFTCreator.tsx @@ -1,7 +1,7 @@ -import { useOnchainKit } from '../../../core-react/useOnchainKit'; -import { Avatar, Badge, Identity, Name } from '../../../identity'; -import { cn } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { Avatar, Badge, Identity, Name } from '../../../../identity'; +import { cn } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTCreatorReact = { className?: string; diff --git a/src/nft/components/mint/NFTMintButton.test.tsx b/src/ui/react/nft/mint/NFTMintButton.test.tsx similarity index 100% rename from src/nft/components/mint/NFTMintButton.test.tsx rename to src/ui/react/nft/mint/NFTMintButton.test.tsx diff --git a/src/nft/components/mint/NFTMintButton.tsx b/src/ui/react/nft/mint/NFTMintButton.tsx similarity index 90% rename from src/nft/components/mint/NFTMintButton.tsx rename to src/ui/react/nft/mint/NFTMintButton.tsx index 5858ee0041..c8c5c86770 100644 --- a/src/nft/components/mint/NFTMintButton.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useAccount, useChainId } from 'wagmi'; -import { Spinner } from '../../../internal/components/Spinner'; -import { cn, color, text } from '../../../styles/theme'; +import { Spinner } from '../../../../internal/components/Spinner'; +import { cn, color, text } from '../../../../styles/theme'; import { Transaction, TransactionButton, @@ -11,11 +11,11 @@ import { TransactionStatus, TransactionStatusAction, TransactionStatusLabel, -} from '../../../transaction'; -import type { Call } from '../../../transaction/types'; -import { ConnectWallet } from '../../../wallet'; -import { useNFTLifecycleContext } from '../NFTLifecycleProvider'; -import { useNFTContext } from '../NFTProvider'; +} from '../../../../transaction'; +import type { Call } from '../../../../transaction/types'; +import { ConnectWallet } from '../../../../wallet'; +import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTMintButtonReact = { className?: string; diff --git a/src/nft/components/mint/NFTMinters.test.tsx b/src/ui/react/nft/mint/NFTMinters.test.tsx similarity index 100% rename from src/nft/components/mint/NFTMinters.test.tsx rename to src/ui/react/nft/mint/NFTMinters.test.tsx diff --git a/src/nft/components/mint/NFTMinters.tsx b/src/ui/react/nft/mint/NFTMinters.tsx similarity index 81% rename from src/nft/components/mint/NFTMinters.tsx rename to src/ui/react/nft/mint/NFTMinters.tsx index 45a0008b9a..300f894e65 100644 --- a/src/nft/components/mint/NFTMinters.tsx +++ b/src/ui/react/nft/mint/NFTMinters.tsx @@ -1,7 +1,7 @@ -import { useOnchainKit } from '../../../core-react/useOnchainKit'; -import { Avatar, Identity, Name } from '../../../identity'; -import { cn, color, text } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { Avatar, Identity, Name } from '../../../../identity'; +import { cn, color, text } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTMintersReact = { className?: string; diff --git a/src/nft/components/mint/NFTQuantitySelector.test.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx similarity index 100% rename from src/nft/components/mint/NFTQuantitySelector.test.tsx rename to src/ui/react/nft/mint/NFTQuantitySelector.test.tsx diff --git a/src/nft/components/mint/NFTQuantitySelector.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.tsx similarity index 72% rename from src/nft/components/mint/NFTQuantitySelector.tsx rename to src/ui/react/nft/mint/NFTQuantitySelector.tsx index 43eb81c04a..dfd28722c7 100644 --- a/src/nft/components/mint/NFTQuantitySelector.tsx +++ b/src/ui/react/nft/mint/NFTQuantitySelector.tsx @@ -1,6 +1,6 @@ -import { QuantitySelector } from '../../../internal/components/QuantitySelector'; -import { cn } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { QuantitySelector } from '../../../../internal/components/QuantitySelector'; +import { cn } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTQuantitySelectorReact = { className?: string; diff --git a/src/nft/components/mint/NFTTotalCost.test.tsx b/src/ui/react/nft/mint/NFTTotalCost.test.tsx similarity index 100% rename from src/nft/components/mint/NFTTotalCost.test.tsx rename to src/ui/react/nft/mint/NFTTotalCost.test.tsx diff --git a/src/nft/components/mint/NFTTotalCost.tsx b/src/ui/react/nft/mint/NFTTotalCost.tsx similarity index 90% rename from src/nft/components/mint/NFTTotalCost.tsx rename to src/ui/react/nft/mint/NFTTotalCost.tsx index 45f9191ba1..f000905bcd 100644 --- a/src/nft/components/mint/NFTTotalCost.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.tsx @@ -1,9 +1,9 @@ import { type ReactNode, useCallback, useMemo, useState } from 'react'; -import { multiplyFloats } from '../../../core/utils/multiplyFloats'; -import { infoSvg } from '../../../internal/svg/infoSvg'; -import { background, border, cn, text } from '../../../styles/theme'; -import { formatAmount } from '../../../token/utils/formatAmount'; -import { useNFTContext } from '../NFTProvider'; +import { multiplyFloats } from '../../../../core/utils/multiplyFloats'; +import { infoSvg } from '../../../../internal/svg/infoSvg'; +import { background, border, cn, text } from '../../../../styles/theme'; +import { formatAmount } from '../../../../token/utils/formatAmount'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTTotalCostReact = { className?: string; diff --git a/src/nft/components/mint/index.ts b/src/ui/react/nft/mint/index.ts similarity index 100% rename from src/nft/components/mint/index.ts rename to src/ui/react/nft/mint/index.ts diff --git a/src/nft/components/view/NFTAudio.test.tsx b/src/ui/react/nft/view/NFTAudio.test.tsx similarity index 100% rename from src/nft/components/view/NFTAudio.test.tsx rename to src/ui/react/nft/view/NFTAudio.test.tsx diff --git a/src/nft/components/view/NFTAudio.tsx b/src/ui/react/nft/view/NFTAudio.tsx similarity index 92% rename from src/nft/components/view/NFTAudio.tsx rename to src/ui/react/nft/view/NFTAudio.tsx index 970928bc6b..c34c705f45 100644 --- a/src/nft/components/view/NFTAudio.tsx +++ b/src/ui/react/nft/view/NFTAudio.tsx @@ -5,9 +5,9 @@ import { useRef, useState, } from 'react'; -import { background, cn } from '../../../styles/theme'; -import type { NFTError } from '../../types'; -import { useNFTContext } from '../NFTProvider'; +import { background, cn } from '../../../../styles/theme'; +import type { NFTError } from '../../../../core-react/nft/types'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTAudioReact = { className?: string; diff --git a/src/nft/components/view/NFTImage.test.tsx b/src/ui/react/nft/view/NFTImage.test.tsx similarity index 100% rename from src/nft/components/view/NFTImage.test.tsx rename to src/ui/react/nft/view/NFTImage.test.tsx diff --git a/src/nft/components/view/NFTImage.tsx b/src/ui/react/nft/view/NFTImage.tsx similarity index 89% rename from src/nft/components/view/NFTImage.tsx rename to src/ui/react/nft/view/NFTImage.tsx index 00404b925f..4ea745d019 100644 --- a/src/nft/components/view/NFTImage.tsx +++ b/src/ui/react/nft/view/NFTImage.tsx @@ -1,8 +1,8 @@ import { type MouseEvent, useCallback, useEffect, useState } from 'react'; -import { defaultNFTSvg } from '../../../internal/svg/defaultNFTSvg'; -import { cn } from '../../../styles/theme'; -import type { NFTError } from '../../types'; -import { useNFTContext } from '../NFTProvider'; +import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; +import { cn } from '../../../../styles/theme'; +import type { NFTError } from '../../../../core-react/nft/types'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTImageReact = { className?: string; diff --git a/src/nft/components/view/NFTLastSoldPrice.test.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx similarity index 100% rename from src/nft/components/view/NFTLastSoldPrice.test.tsx rename to src/ui/react/nft/view/NFTLastSoldPrice.test.tsx diff --git a/src/nft/components/view/NFTLastSoldPrice.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.tsx similarity index 76% rename from src/nft/components/view/NFTLastSoldPrice.tsx rename to src/ui/react/nft/view/NFTLastSoldPrice.tsx index 3a1bfcbaaf..87cbf8fff7 100644 --- a/src/nft/components/view/NFTLastSoldPrice.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.tsx @@ -1,8 +1,8 @@ import type { ReactNode } from 'react'; -import { cn, color, text } from '../../../styles/theme'; -import { formatAmount as formatSN } from '../../../swap/utils/formatAmount'; -import { formatAmount } from '../../../token/utils/formatAmount'; -import { useNFTContext } from '../NFTProvider'; +import { cn, color, text } from '../../../../styles/theme'; +import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; +import { formatAmount } from '../../../../token/utils/formatAmount'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTLastSoldPriceReact = { className?: string; diff --git a/src/nft/components/view/NFTMedia.test.tsx b/src/ui/react/nft/view/NFTMedia.test.tsx similarity index 100% rename from src/nft/components/view/NFTMedia.test.tsx rename to src/ui/react/nft/view/NFTMedia.test.tsx diff --git a/src/nft/components/view/NFTMedia.tsx b/src/ui/react/nft/view/NFTMedia.tsx similarity index 94% rename from src/nft/components/view/NFTMedia.tsx rename to src/ui/react/nft/view/NFTMedia.tsx index 2b78e776fb..e43928572f 100644 --- a/src/nft/components/view/NFTMedia.tsx +++ b/src/ui/react/nft/view/NFTMedia.tsx @@ -1,6 +1,6 @@ import { useCallback, useMemo } from 'react'; -import { cn } from '../../../styles/theme'; -import { LifecycleType, MediaType, type NFTError } from '../../types'; +import { cn } from '../../../../../styles/theme'; +import { LifecycleType, MediaType, type NFTError } from '../../../../../core/nft/types'; import { useNFTLifecycleContext } from '../NFTLifecycleProvider'; import { useNFTContext } from '../NFTProvider'; import { NFTAudio } from './NFTAudio'; diff --git a/src/nft/components/view/NFTMintDate.test.tsx b/src/ui/react/nft/view/NFTMintDate.test.tsx similarity index 100% rename from src/nft/components/view/NFTMintDate.test.tsx rename to src/ui/react/nft/view/NFTMintDate.test.tsx diff --git a/src/nft/components/view/NFTMintDate.tsx b/src/ui/react/nft/view/NFTMintDate.tsx similarity index 86% rename from src/nft/components/view/NFTMintDate.tsx rename to src/ui/react/nft/view/NFTMintDate.tsx index 24cb359822..44a63599d6 100644 --- a/src/nft/components/view/NFTMintDate.tsx +++ b/src/ui/react/nft/view/NFTMintDate.tsx @@ -1,6 +1,6 @@ import { type ReactNode, useMemo } from 'react'; -import { cn, color, text } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { cn, color, text } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; const DATE_OPTIONS = { year: 'numeric', diff --git a/src/nft/components/view/NFTNetwork.test.tsx b/src/ui/react/nft/view/NFTNetwork.test.tsx similarity index 100% rename from src/nft/components/view/NFTNetwork.test.tsx rename to src/ui/react/nft/view/NFTNetwork.test.tsx diff --git a/src/nft/components/view/NFTNetwork.tsx b/src/ui/react/nft/view/NFTNetwork.tsx similarity index 88% rename from src/nft/components/view/NFTNetwork.tsx rename to src/ui/react/nft/view/NFTNetwork.tsx index 94afe0f649..ae26c2328d 100644 --- a/src/nft/components/view/NFTNetwork.tsx +++ b/src/ui/react/nft/view/NFTNetwork.tsx @@ -1,8 +1,8 @@ import type { ReactNode } from 'react'; import { type Chain, base } from 'viem/chains'; import { useChainId } from 'wagmi'; -import { baseSvg } from '../../../internal/svg/baseSvg'; -import { cn, color, text } from '../../../styles/theme'; +import { baseSvg } from '../../../../internal/svg/baseSvg'; +import { cn, color, text } from '../../../../styles/theme'; type NFTNetworkReact = { className?: string; diff --git a/src/nft/components/view/NFTOwner.test.tsx b/src/ui/react/nft/view/NFTOwner.test.tsx similarity index 100% rename from src/nft/components/view/NFTOwner.test.tsx rename to src/ui/react/nft/view/NFTOwner.test.tsx diff --git a/src/nft/components/view/NFTOwner.tsx b/src/ui/react/nft/view/NFTOwner.tsx similarity index 74% rename from src/nft/components/view/NFTOwner.tsx rename to src/ui/react/nft/view/NFTOwner.tsx index 5b9ef6040d..03fc16463c 100644 --- a/src/nft/components/view/NFTOwner.tsx +++ b/src/ui/react/nft/view/NFTOwner.tsx @@ -1,8 +1,8 @@ import type { ReactNode } from 'react'; -import { useOnchainKit } from '../../../core-react/useOnchainKit'; -import { Avatar, Badge, Identity, Name } from '../../../identity'; -import { cn, color, text } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { Avatar, Badge, Identity, Name } from '../../../../identity'; +import { cn, color, text } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTOwnerReact = { className?: string; diff --git a/src/nft/components/view/NFTTitle.test.tsx b/src/ui/react/nft/view/NFTTitle.test.tsx similarity index 100% rename from src/nft/components/view/NFTTitle.test.tsx rename to src/ui/react/nft/view/NFTTitle.test.tsx diff --git a/src/nft/components/view/NFTTitle.tsx b/src/ui/react/nft/view/NFTTitle.tsx similarity index 70% rename from src/nft/components/view/NFTTitle.tsx rename to src/ui/react/nft/view/NFTTitle.tsx index 47b947c4a4..36fb081724 100644 --- a/src/nft/components/view/NFTTitle.tsx +++ b/src/ui/react/nft/view/NFTTitle.tsx @@ -1,5 +1,5 @@ -import { cn, text } from '../../../styles/theme'; -import { useNFTContext } from '../NFTProvider'; +import { cn, text } from '../../../../styles/theme'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTTitleReact = { className?: string; diff --git a/src/nft/components/view/NFTVideo.test.tsx b/src/ui/react/nft/view/NFTVideo.test.tsx similarity index 94% rename from src/nft/components/view/NFTVideo.test.tsx rename to src/ui/react/nft/view/NFTVideo.test.tsx index bcdcaa3758..6f02e3e2fe 100644 --- a/src/nft/components/view/NFTVideo.test.tsx +++ b/src/ui/react/nft/view/NFTVideo.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTVideo } from './NFTVideo'; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/nft/components/view/NFTVideo.tsx b/src/ui/react/nft/view/NFTVideo.tsx similarity index 86% rename from src/nft/components/view/NFTVideo.tsx rename to src/ui/react/nft/view/NFTVideo.tsx index e14d475147..ea3010cd15 100644 --- a/src/nft/components/view/NFTVideo.tsx +++ b/src/ui/react/nft/view/NFTVideo.tsx @@ -1,8 +1,8 @@ import { useEffect, useRef } from 'react'; -import { defaultNFTSvg } from '../../../internal/svg/defaultNFTSvg'; -import { cn } from '../../../styles/theme'; -import type { NFTError } from '../../types'; -import { useNFTContext } from '../NFTProvider'; +import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; +import { cn } from '../../../../styles/theme'; +import type { NFTError } from '../../../../core-react/nft/types'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTVideoReact = { className?: string; diff --git a/src/nft/components/view/index.ts b/src/ui/react/nft/view/index.ts similarity index 100% rename from src/nft/components/view/index.ts rename to src/ui/react/nft/view/index.ts From bea62e223ef18f0e60216be131c9fef56dc7054a Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Tue, 10 Dec 2024 16:57:44 -0500 Subject: [PATCH 2/9] fix: lint/tests --- src/core-react/nft/hooks/useMintData.test.ts | 2 +- src/core-react/nft/hooks/useMintData.ts | 2 +- .../nft/hooks/useMintDetails.test.ts | 6 +- src/core-react/nft/hooks/useMintDetails.ts | 5 +- src/core-react/nft/hooks/useNFTData.test.ts | 4 +- src/core-react/nft/hooks/useNFTData.ts | 2 +- .../nft/hooks/useTokenDetails.test.ts | 6 +- src/core-react/nft/hooks/useTokenDetails.ts | 5 +- .../utils/buildMintTransactionData.test.ts | 2 +- .../nft/utils/buildMintTransactionData.ts | 2 +- src/ui/react/nft/NFTCard.test.tsx | 14 ++- src/ui/react/nft/NFTCard.tsx | 2 - src/ui/react/nft/NFTMintCard.test.tsx | 11 ++ src/ui/react/nft/components/view/NFTAudio.tsx | 105 ------------------ src/ui/react/nft/components/view/NFTImage.tsx | 97 ---------------- src/ui/react/nft/components/view/NFTVideo.tsx | 74 ------------ src/ui/react/nft/mint/NFTAssetCost.test.tsx | 4 +- src/ui/react/nft/mint/NFTAssetCost.tsx | 2 +- .../nft/mint/NFTCollectionTitle.test.tsx | 4 +- src/ui/react/nft/mint/NFTCollectionTitle.tsx | 2 +- src/ui/react/nft/mint/NFTCreator.test.tsx | 12 +- src/ui/react/nft/mint/NFTMintButton.test.tsx | 17 ++- src/ui/react/nft/mint/NFTMintButton.tsx | 4 +- src/ui/react/nft/mint/NFTMinters.test.tsx | 8 +- .../nft/mint/NFTQuantitySelector.test.tsx | 6 +- src/ui/react/nft/mint/NFTQuantitySelector.tsx | 2 +- src/ui/react/nft/mint/NFTTotalCost.test.tsx | 4 +- src/ui/react/nft/mint/NFTTotalCost.tsx | 2 +- src/ui/react/nft/view/NFTAudio.test.tsx | 4 +- src/ui/react/nft/view/NFTAudio.tsx | 4 +- src/ui/react/nft/view/NFTImage.test.tsx | 4 +- src/ui/react/nft/view/NFTImage.tsx | 4 +- .../react/nft/view/NFTLastSoldPrice.test.tsx | 4 +- src/ui/react/nft/view/NFTLastSoldPrice.tsx | 2 +- src/ui/react/nft/view/NFTMedia.test.tsx | 10 +- src/ui/react/nft/view/NFTMedia.tsx | 12 +- src/ui/react/nft/view/NFTMintDate.test.tsx | 4 +- src/ui/react/nft/view/NFTMintDate.tsx | 2 +- src/ui/react/nft/view/NFTOwner.test.tsx | 8 +- src/ui/react/nft/view/NFTTitle.test.tsx | 4 +- src/ui/react/nft/view/NFTTitle.tsx | 2 +- src/ui/react/nft/view/NFTVideo.tsx | 4 +- 42 files changed, 120 insertions(+), 354 deletions(-) delete mode 100644 src/ui/react/nft/components/view/NFTAudio.tsx delete mode 100644 src/ui/react/nft/components/view/NFTImage.tsx delete mode 100644 src/ui/react/nft/components/view/NFTVideo.tsx diff --git a/src/core-react/nft/hooks/useMintData.test.ts b/src/core-react/nft/hooks/useMintData.test.ts index e5d9fac766..3f38bfa6c1 100644 --- a/src/core-react/nft/hooks/useMintData.test.ts +++ b/src/core-react/nft/hooks/useMintData.test.ts @@ -13,7 +13,7 @@ import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import { useMintData } from './useMintData'; import { useMintDetails } from './useMintDetails'; -vi.mock('../components/NFTLifecycleProvider'); +vi.mock('../providers/NFTLifecycleProvider'); vi.mock('./useMintDetails'); vi.mock('wagmi'); diff --git a/src/core-react/nft/hooks/useMintData.ts b/src/core-react/nft/hooks/useMintData.ts index e98e66ef1e..1f23870498 100644 --- a/src/core-react/nft/hooks/useMintData.ts +++ b/src/core-react/nft/hooks/useMintData.ts @@ -1,8 +1,8 @@ import { useEffect, useState } from 'react'; import { useAccount } from 'wagmi'; +import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import type { NFTData, NFTError } from '../types'; -import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useMintDetails } from './useMintDetails'; export function useMintData( diff --git a/src/core-react/nft/hooks/useMintDetails.test.ts b/src/core-react/nft/hooks/useMintDetails.test.ts index 1497a6f228..3b8094d119 100644 --- a/src/core-react/nft/hooks/useMintDetails.test.ts +++ b/src/core-react/nft/hooks/useMintDetails.test.ts @@ -1,10 +1,10 @@ import { renderHook, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { getMintDetails } from '../../core/api/getMintDetails'; -import { getNewReactQueryTestProvider } from '../../identity/hooks/getNewReactQueryTestProvider'; +import { getMintDetails } from '../../../core/api/getMintDetails'; +import { getNewReactQueryTestProvider } from '../../../identity/hooks/getNewReactQueryTestProvider'; import { useMintDetails } from './useMintDetails'; -vi.mock('../../core/api/getMintDetails'); +vi.mock('../../../core/api/getMintDetails'); describe('useMintDetails', () => { beforeEach(() => { diff --git a/src/core-react/nft/hooks/useMintDetails.ts b/src/core-react/nft/hooks/useMintDetails.ts index 1da10b2cd8..24f53d0576 100644 --- a/src/core-react/nft/hooks/useMintDetails.ts +++ b/src/core-react/nft/hooks/useMintDetails.ts @@ -1,6 +1,9 @@ import { type UseQueryResult, useQuery } from '@tanstack/react-query'; import { getMintDetails } from '../../../core/api/getMintDetails'; -import type { GetMintDetailsParams, MintDetails } from '../../../core/api/types'; +import type { + GetMintDetailsParams, + MintDetails, +} from '../../../core/api/types'; import { isNFTError } from '../../../core/nft/utils/isNFTError'; export function useMintDetails({ diff --git a/src/core-react/nft/hooks/useNFTData.test.ts b/src/core-react/nft/hooks/useNFTData.test.ts index e7330cec3b..aa3598c681 100644 --- a/src/core-react/nft/hooks/useNFTData.test.ts +++ b/src/core-react/nft/hooks/useNFTData.test.ts @@ -8,12 +8,12 @@ import { it, vi, } from 'vitest'; -import { useNFTLifecycleContext } from '../components/NFTLifecycleProvider'; +import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import { useNFTData } from './useNFTData'; import { useTokenDetails } from './useTokenDetails'; vi.mock('./useTokenDetails'); -vi.mock('../components/NFTLifecycleProvider'); +vi.mock('../providers/NFTLifecycleProvider'); describe('useNFTData', () => { const mockUpdateLifecycleStatus = vi.fn(); diff --git a/src/core-react/nft/hooks/useNFTData.ts b/src/core-react/nft/hooks/useNFTData.ts index 33bc46bbb6..b4f3127b9f 100644 --- a/src/core-react/nft/hooks/useNFTData.ts +++ b/src/core-react/nft/hooks/useNFTData.ts @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; +import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import type { ContractType, NFTData, NFTError } from '../types'; -import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useTokenDetails } from './useTokenDetails'; export function useNFTData( diff --git a/src/core-react/nft/hooks/useTokenDetails.test.ts b/src/core-react/nft/hooks/useTokenDetails.test.ts index d5c93d8204..a03d5b831a 100644 --- a/src/core-react/nft/hooks/useTokenDetails.test.ts +++ b/src/core-react/nft/hooks/useTokenDetails.test.ts @@ -1,10 +1,10 @@ import { renderHook, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { getTokenDetails } from '../../core/api/getTokenDetails'; -import { getNewReactQueryTestProvider } from '../../identity/hooks/getNewReactQueryTestProvider'; +import { getTokenDetails } from '../../../core/api/getTokenDetails'; +import { getNewReactQueryTestProvider } from '../../../identity/hooks/getNewReactQueryTestProvider'; import { useTokenDetails } from './useTokenDetails'; -vi.mock('../../core/api/getTokenDetails'); +vi.mock('../../../core/api/getTokenDetails'); describe('useTokenDetails', () => { beforeEach(() => { diff --git a/src/core-react/nft/hooks/useTokenDetails.ts b/src/core-react/nft/hooks/useTokenDetails.ts index 3df2220b99..b4194e8ab6 100644 --- a/src/core-react/nft/hooks/useTokenDetails.ts +++ b/src/core-react/nft/hooks/useTokenDetails.ts @@ -1,6 +1,9 @@ import { type UseQueryResult, useQuery } from '@tanstack/react-query'; import { getTokenDetails } from '../../../core/api/getTokenDetails'; -import type { GetTokenDetailsParams, TokenDetails } from '../../../core/api/types'; +import type { + GetTokenDetailsParams, + TokenDetails, +} from '../../../core/api/types'; import { isNFTError } from '../../../core/nft/utils/isNFTError'; export function useTokenDetails({ diff --git a/src/core/nft/utils/buildMintTransactionData.test.ts b/src/core/nft/utils/buildMintTransactionData.test.ts index d6c036f9f1..662220f841 100644 --- a/src/core/nft/utils/buildMintTransactionData.test.ts +++ b/src/core/nft/utils/buildMintTransactionData.test.ts @@ -3,7 +3,7 @@ import { type Mock, describe, expect, it, vi } from 'vitest'; import { buildMintTransaction as buildMintTransationApi } from '../../api/buildMintTransaction'; import { buildMintTransactionData } from './buildMintTransactionData'; -vi.mock('../../core/api/buildMintTransaction'); +vi.mock('../../api/buildMintTransaction'); describe('buildMintTransactionData', () => { const mockBuildMintTransaction = buildMintTransationApi as Mock; diff --git a/src/core/nft/utils/buildMintTransactionData.ts b/src/core/nft/utils/buildMintTransactionData.ts index bec600e14d..8006fe4a3b 100644 --- a/src/core/nft/utils/buildMintTransactionData.ts +++ b/src/core/nft/utils/buildMintTransactionData.ts @@ -1,7 +1,7 @@ import type { Address } from 'viem'; +import type { Call } from '../../../transaction/types'; import { buildMintTransaction as buildMintTransactionApi } from '../../api/buildMintTransaction'; import type { BuildMintTransactionParams } from '../../api/types'; -import type { Call } from '../../../transaction/types'; async function getMintTransaction({ mintAddress, diff --git a/src/ui/react/nft/NFTCard.test.tsx b/src/ui/react/nft/NFTCard.test.tsx index 43be352348..4b2da9f212 100644 --- a/src/ui/react/nft/NFTCard.test.tsx +++ b/src/ui/react/nft/NFTCard.test.tsx @@ -10,18 +10,30 @@ import { vi, } from 'vitest'; import { useAccount } from 'wagmi'; +<<<<<<< HEAD import { useIsMounted } from '../../core-react/internal/hooks/useIsMounted'; +======= +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; +import { useIsMounted } from '../../../useIsMounted'; +>>>>>>> 38ec07ca (fix: lint/tests) import { NFTCard } from './NFTCard'; -import { NFTProvider } from './NFTProvider'; vi.mock('wagmi', () => ({ useAccount: vi.fn(), })); +<<<<<<< HEAD vi.mock('../../core-react/internal/hooks/useTheme', () => ({ useTheme: vi.fn(() => 'default-light'), })); vi.mock('../../core-react/internal/hooks/useIsMounted'); vi.mock('./NFTProvider', () => ({ +======= +vi.mock('../../../useTheme', () => ({ + useTheme: vi.fn(() => 'default-light'), +})); +vi.mock('../../../useIsMounted'); +vi.mock('../../../core-react/nft/providers/NFTProvider', () => ({ +>>>>>>> 38ec07ca (fix: lint/tests) NFTProvider: vi.fn(({ children }) =>
{children}
), })); diff --git a/src/ui/react/nft/NFTCard.tsx b/src/ui/react/nft/NFTCard.tsx index 86f4a13c30..abae0f87e4 100644 --- a/src/ui/react/nft/NFTCard.tsx +++ b/src/ui/react/nft/NFTCard.tsx @@ -7,8 +7,6 @@ import { useNFTData as defaultUseNFTData } from '../../../core-react/nft/hooks/u import { LifecycleType, type NFTCardReact } from '../../../core-react/nft/types'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; -import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; export function NFTCard({ children, diff --git a/src/ui/react/nft/NFTMintCard.test.tsx b/src/ui/react/nft/NFTMintCard.test.tsx index acb2799e40..e8ff5f7c9c 100644 --- a/src/ui/react/nft/NFTMintCard.test.tsx +++ b/src/ui/react/nft/NFTMintCard.test.tsx @@ -9,6 +9,7 @@ import { it, vi, } from 'vitest'; +<<<<<<< HEAD import { useIsMounted } from '../../core-react/internal/hooks/useIsMounted'; import { NFTMintCard } from './NFTMintCard'; @@ -17,6 +18,16 @@ vi.mock('../../core-react/internal/hooks/useTheme', () => ({ })); vi.mock('../../core-react/internal/hooks/useIsMounted'); vi.mock('./NFTProvider', () => ({ +======= +import { useIsMounted } from '../../../useIsMounted'; +import { NFTMintCard } from './NFTMintCard'; + +vi.mock('../../../useTheme', () => ({ + useTheme: vi.fn(() => 'default-light'), +})); +vi.mock('../../../useIsMounted'); +vi.mock('../../../core-react/nft/providers/NFTProvider', () => ({ +>>>>>>> 38ec07ca (fix: lint/tests) NFTProvider: vi.fn(({ children }) =>
{children}
), })); diff --git a/src/ui/react/nft/components/view/NFTAudio.tsx b/src/ui/react/nft/components/view/NFTAudio.tsx deleted file mode 100644 index c9c8fcffbc..0000000000 --- a/src/ui/react/nft/components/view/NFTAudio.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import { - type MouseEvent, - useCallback, - useEffect, - useRef, - useState, -} from 'react'; -import { background, cn } from '../../../../../styles/theme'; -import type { NFTError } from '../../../../../core-react/nft/types'; -import { useNFTContext } from '../../../../../core-react/nft/providers/NFTProvider'; - -type NFTAudioReact = { - className?: string; - onLoading?: (mediaUrl: string) => void; - onLoaded?: () => void; - onError?: (error: NFTError) => void; -}; - -export function NFTAudio({ - className, - onLoading, - onLoaded, - onError, -}: NFTAudioReact) { - const { animationUrl } = useNFTContext(); - const audioRef = useRef(null); - const [isPlaying, setIsPlaying] = useState(false); - - useEffect(() => { - function onEnded() { - setIsPlaying(false); - } - - if (animationUrl && audioRef?.current) { - audioRef.current.onloadstart = () => { - onLoading?.(animationUrl); - }; - - audioRef.current.onloadeddata = () => { - onLoaded?.(); - }; - - audioRef.current.addEventListener('ended', onEnded); - - audioRef.current.onerror = (error: string | Event) => { - onError?.({ - error: typeof error === 'string' ? error : error.type, - code: 'NmNAc01', // NFT module NFTAudio component 01 error - message: 'Error loading audio', - }); - }; - } - }, [animationUrl, onLoading, onLoaded, onError]); - - const handlePlayPause = useCallback( - (event: MouseEvent) => { - event.stopPropagation(); - if (isPlaying) { - audioRef.current?.pause(); - setIsPlaying(false); - } else { - audioRef.current?.play(); - setIsPlaying(true); - } - }, - [isPlaying], - ); - - if (!animationUrl) { - return null; - } - - return ( -
- - -
- ); -} diff --git a/src/ui/react/nft/components/view/NFTImage.tsx b/src/ui/react/nft/components/view/NFTImage.tsx deleted file mode 100644 index dd76c71ea8..0000000000 --- a/src/ui/react/nft/components/view/NFTImage.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import { type MouseEvent, useCallback, useEffect, useState } from 'react'; -import { defaultNFTSvg } from '../../../../../internal/svg/defaultNFTSvg'; -import { cn } from '../../../../../styles/theme'; -import type { NFTError } from '../../../../../core-react/nft/types'; -import { useNFTContext } from '../../../../../core-react/nft/providers/NFTProvider'; - -type NFTImageReact = { - className?: string; - square?: boolean; - onLoading?: (mediaUrl: string) => void; - onLoaded?: () => void; - onError?: (error: NFTError) => void; -}; - -export function NFTImage({ - className, - square = true, - onLoading, - onLoaded, - onError, -}: NFTImageReact) { - const { imageUrl, description } = useNFTContext(); - const [loaded, setLoaded] = useState(false); - const [error, setError] = useState(false); - - const loadImage = useCallback(() => { - if (imageUrl) { - onLoading?.(imageUrl); - - const img = new Image(); - img.onload = () => { - setLoaded(true); - onLoaded?.(); - }; - - img.onerror = (error: string | Event) => { - onError?.({ - error: typeof error === 'string' ? error : error.type, - code: 'NmNIc01', // NFT module NFTImage component 01 error - message: 'Error loading image', - }); - setError(true); - }; - img.src = imageUrl; - } - }, [imageUrl, onLoading, onLoaded, onError]); - - useEffect(() => { - loadImage(); - }, [loadImage]); - - const handleRetry = useCallback( - async (e: MouseEvent) => { - e.stopPropagation(); - setError(false); - loadImage(); - }, - [loadImage], - ); - - return ( -
*]:col-start-1 [&>*]:col-end-1 [&>*]:row-start-1 [&>*]:row-end-1', - className, - )} - > -
{defaultNFTSvg}
-
- {description} -
- {error && ( -
- -
- )} -
- ); -} diff --git a/src/ui/react/nft/components/view/NFTVideo.tsx b/src/ui/react/nft/components/view/NFTVideo.tsx deleted file mode 100644 index a2ffcd319d..0000000000 --- a/src/ui/react/nft/components/view/NFTVideo.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { useEffect, useRef } from 'react'; -import { defaultNFTSvg } from '../../../../../internal/svg/defaultNFTSvg'; -import { cn } from '../../../../../styles/theme'; -import type { NFTError } from '../../../../../core-react/nft/types'; -import { useNFTContext } from '../../../../../core-react/nft/providers/NFTProvider'; - -type NFTVideoReact = { - className?: string; - square?: boolean; - onLoading?: (mediaUrl: string) => void; - onLoaded?: () => void; - onError?: (error: NFTError) => void; -}; - -export function NFTVideo({ - className, - square = true, - onLoading, - onLoaded, - onError, -}: NFTVideoReact) { - const { animationUrl, imageUrl } = useNFTContext(); - const videoRef = useRef(null); - - useEffect(() => { - if (animationUrl && videoRef?.current) { - videoRef.current.onloadstart = () => { - onLoading?.(animationUrl); - }; - - videoRef.current.onloadeddata = () => { - onLoaded?.(); - }; - - videoRef.current.onerror = (error: string | Event) => { - onError?.({ - error: typeof error === 'string' ? error : error.type, - code: 'NmNVc01', // NFT module NFTVideo component 01 error - message: 'Error loading video', - }); - }; - } - }, [animationUrl, onLoading, onLoaded, onError]); - - if (!animationUrl) { - return
{defaultNFTSvg}
; - } - - return ( -
*]:col-start-1 [&>*]:col-end-1 [&>*]:row-start-1 [&>*]:row-end-1', - { 'content-center justify-center': !square }, - className, - )} - > -
- ); -} diff --git a/src/ui/react/nft/mint/NFTAssetCost.test.tsx b/src/ui/react/nft/mint/NFTAssetCost.test.tsx index 244fdf9e2c..69f0775d04 100644 --- a/src/ui/react/nft/mint/NFTAssetCost.test.tsx +++ b/src/ui/react/nft/mint/NFTAssetCost.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTAssetCost } from './NFTAssetCost'; -vi.mock('../NFTProvider'); +vi.mock('../../../../core-react/nft/providers/NFTProvider'); describe('NFTAssetCost', () => { const mockUseNFTContext = useNFTContext as Mock; diff --git a/src/ui/react/nft/mint/NFTAssetCost.tsx b/src/ui/react/nft/mint/NFTAssetCost.tsx index 59a021b1a6..47d01a267b 100644 --- a/src/ui/react/nft/mint/NFTAssetCost.tsx +++ b/src/ui/react/nft/mint/NFTAssetCost.tsx @@ -1,8 +1,8 @@ +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { multiplyFloats } from '../../../../core/utils/multiplyFloats'; import { cn, text } from '../../../../styles/theme'; import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; import { formatAmount } from '../../../../token/utils/formatAmount'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTAssetCostReact = { className?: string; diff --git a/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx index b46718713d..4e07fcba06 100644 --- a/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx +++ b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTCollectionTitle } from './NFTCollectionTitle'; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/mint/NFTCollectionTitle.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.tsx index 4a1a3c087f..d796e00290 100644 --- a/src/ui/react/nft/mint/NFTCollectionTitle.tsx +++ b/src/ui/react/nft/mint/NFTCollectionTitle.tsx @@ -1,5 +1,5 @@ -import { cn, text } from '../../../../styles/theme'; import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { cn, text } from '../../../../styles/theme'; type NFTCollectionTitleReact = { className?: string; diff --git a/src/ui/react/nft/mint/NFTCreator.test.tsx b/src/ui/react/nft/mint/NFTCreator.test.tsx index cc326a2043..4e716b147c 100644 --- a/src/ui/react/nft/mint/NFTCreator.test.tsx +++ b/src/ui/react/nft/mint/NFTCreator.test.tsx @@ -1,19 +1,19 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useOnchainKit } from '../../../core-react/useOnchainKit'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '../../../../core-react/useOnchainKit'; import { NFTCreator } from './NFTCreator'; -vi.mock('../../../core-react/useOnchainKit', () => ({ +vi.mock('../../../../core-react/useOnchainKit', () => ({ useOnchainKit: vi.fn(), })); -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); -vi.mock('../../../identity', async () => ({ - ...(await vi.importActual('../../../identity')), +vi.mock('../../../../identity', async () => ({ + ...(await vi.importActual('../../../../identity')), Identity: ({ className }: { className: string }) => (
Identity
), diff --git a/src/ui/react/nft/mint/NFTMintButton.test.tsx b/src/ui/react/nft/mint/NFTMintButton.test.tsx index 548f02793e..284cb6136e 100644 --- a/src/ui/react/nft/mint/NFTMintButton.test.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.test.tsx @@ -11,6 +11,7 @@ import { useChainId, } from 'wagmi'; import { mock } from 'wagmi/connectors'; +<<<<<<< HEAD import { useOnchainKit } from '../../../core-react/useOnchainKit'; import { useNFTLifecycleContext } from '../NFTLifecycleProvider'; import { useNFTContext } from '../NFTProvider'; @@ -19,6 +20,16 @@ import { NFTMintButton } from './NFTMintButton'; vi.mock('../NFTProvider'); vi.mock('../NFTLifecycleProvider'); vi.mock('../../../core-react/useOnchainKit'); +======= +import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '../../../../useOnchainKit'; +import { NFTMintButton } from './NFTMintButton'; + +vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('../../../../core-react/nft/providers/NFTLifecycleProvider'); +vi.mock('../../../../useOnchainKit'); +>>>>>>> 38ec07ca (fix: lint/tests) vi.mock('wagmi', async (importOriginal) => { return { ...(await importOriginal()), @@ -29,9 +40,9 @@ vi.mock('wagmi', async (importOriginal) => { vi.mock('../../../internal/components/Spinner', () => ({ Spinner: () =>
Spinner
, })); -vi.mock('../../../transaction', async (importOriginal) => { +vi.mock('../../../../transaction', async (importOriginal) => { return { - ...(await importOriginal()), + ...(await importOriginal()), TransactionLifecycleStatus: vi.fn(), TransactionButton: ({ text, @@ -89,7 +100,7 @@ vi.mock('../../../transaction', async (importOriginal) => { TransactionStatusLabel: vi.fn(), }; }); -vi.mock('../../../wallet', () => ({ +vi.mock('../../../../wallet', () => ({ ConnectWallet: () =>
ConnectWallet
, })); diff --git a/src/ui/react/nft/mint/NFTMintButton.tsx b/src/ui/react/nft/mint/NFTMintButton.tsx index c8c5c86770..365c149af5 100644 --- a/src/ui/react/nft/mint/NFTMintButton.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.tsx @@ -1,5 +1,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useAccount, useChainId } from 'wagmi'; +import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { Spinner } from '../../../../internal/components/Spinner'; import { cn, color, text } from '../../../../styles/theme'; import { @@ -14,8 +16,6 @@ import { } from '../../../../transaction'; import type { Call } from '../../../../transaction/types'; import { ConnectWallet } from '../../../../wallet'; -import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTMintButtonReact = { className?: string; diff --git a/src/ui/react/nft/mint/NFTMinters.test.tsx b/src/ui/react/nft/mint/NFTMinters.test.tsx index aed94df106..5fa1b64dbe 100644 --- a/src/ui/react/nft/mint/NFTMinters.test.tsx +++ b/src/ui/react/nft/mint/NFTMinters.test.tsx @@ -1,13 +1,13 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTMinters } from './NFTMinters'; -vi.mock('../NFTProvider'); +vi.mock('../../../../core-react/nft/providers/NFTProvider'); -vi.mock('../../../identity', async () => ({ - ...(await vi.importActual('../../../identity')), +vi.mock('../../../../identity', async () => ({ + ...(await vi.importActual('../../../../identity')), Identity: ({ className, children, diff --git a/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx index 1af731c9e9..ca7dc433e5 100644 --- a/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx +++ b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx @@ -10,12 +10,12 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTQuantitySelector } from './NFTQuantitySelector'; -vi.mock('../NFTProvider'); +vi.mock('../../../../core-react/nft/providers/NFTProvider'); -vi.mock('../../../internal/components/QuantitySelector', () => ({ +vi.mock('../../../../internal/components/QuantitySelector', () => ({ QuantitySelector: ({ onChange, minQuantity, diff --git a/src/ui/react/nft/mint/NFTQuantitySelector.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.tsx index dfd28722c7..c636e026be 100644 --- a/src/ui/react/nft/mint/NFTQuantitySelector.tsx +++ b/src/ui/react/nft/mint/NFTQuantitySelector.tsx @@ -1,6 +1,6 @@ +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { QuantitySelector } from '../../../../internal/components/QuantitySelector'; import { cn } from '../../../../styles/theme'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTQuantitySelectorReact = { className?: string; diff --git a/src/ui/react/nft/mint/NFTTotalCost.test.tsx b/src/ui/react/nft/mint/NFTTotalCost.test.tsx index 4dce22d588..6016cf3d50 100644 --- a/src/ui/react/nft/mint/NFTTotalCost.test.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTTotalCost } from './NFTTotalCost'; -vi.mock('../NFTProvider'); +vi.mock('../../../../core-react/nft/providers/NFTProvider'); describe('NFTTotalCost', () => { const mockUseNFTContext = useNFTContext as Mock; diff --git a/src/ui/react/nft/mint/NFTTotalCost.tsx b/src/ui/react/nft/mint/NFTTotalCost.tsx index f000905bcd..2376807f00 100644 --- a/src/ui/react/nft/mint/NFTTotalCost.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.tsx @@ -1,9 +1,9 @@ import { type ReactNode, useCallback, useMemo, useState } from 'react'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { multiplyFloats } from '../../../../core/utils/multiplyFloats'; import { infoSvg } from '../../../../internal/svg/infoSvg'; import { background, border, cn, text } from '../../../../styles/theme'; import { formatAmount } from '../../../../token/utils/formatAmount'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTTotalCostReact = { className?: string; diff --git a/src/ui/react/nft/view/NFTAudio.test.tsx b/src/ui/react/nft/view/NFTAudio.test.tsx index af462360cf..4a5bd2c52d 100644 --- a/src/ui/react/nft/view/NFTAudio.test.tsx +++ b/src/ui/react/nft/view/NFTAudio.test.tsx @@ -9,12 +9,12 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTAudio } from './NFTAudio'; const mockAnimationUrl = 'https://example.com/audio.mp3'; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTAudio.tsx b/src/ui/react/nft/view/NFTAudio.tsx index c34c705f45..861065912e 100644 --- a/src/ui/react/nft/view/NFTAudio.tsx +++ b/src/ui/react/nft/view/NFTAudio.tsx @@ -5,9 +5,9 @@ import { useRef, useState, } from 'react'; -import { background, cn } from '../../../../styles/theme'; -import type { NFTError } from '../../../../core-react/nft/types'; import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import type { NFTError } from '../../../../core-react/nft/types'; +import { background, cn } from '../../../../styles/theme'; type NFTAudioReact = { className?: string; diff --git a/src/ui/react/nft/view/NFTImage.test.tsx b/src/ui/react/nft/view/NFTImage.test.tsx index 206f0c8df7..7e43e2f894 100644 --- a/src/ui/react/nft/view/NFTImage.test.tsx +++ b/src/ui/react/nft/view/NFTImage.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; import { fireEvent, render, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTImage } from './NFTImage'; const mockContext = { @@ -9,7 +9,7 @@ const mockContext = { description: 'Test NFT Image', }; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTImage.tsx b/src/ui/react/nft/view/NFTImage.tsx index 4ea745d019..3ec0d7c941 100644 --- a/src/ui/react/nft/view/NFTImage.tsx +++ b/src/ui/react/nft/view/NFTImage.tsx @@ -1,8 +1,8 @@ import { type MouseEvent, useCallback, useEffect, useState } from 'react'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import type { NFTError } from '../../../../core-react/nft/types'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; -import type { NFTError } from '../../../../core-react/nft/types'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTImageReact = { className?: string; diff --git a/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx index 10ced254f7..822eed0c92 100644 --- a/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTLastSoldPrice } from './NFTLastSoldPrice'; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTLastSoldPrice.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.tsx index 87cbf8fff7..12901ce27a 100644 --- a/src/ui/react/nft/view/NFTLastSoldPrice.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.tsx @@ -1,8 +1,8 @@ import type { ReactNode } from 'react'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { cn, color, text } from '../../../../styles/theme'; import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; import { formatAmount } from '../../../../token/utils/formatAmount'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTLastSoldPriceReact = { className?: string; diff --git a/src/ui/react/nft/view/NFTMedia.test.tsx b/src/ui/react/nft/view/NFTMedia.test.tsx index 2356acd94b..f06ead4d16 100644 --- a/src/ui/react/nft/view/NFTMedia.test.tsx +++ b/src/ui/react/nft/view/NFTMedia.test.tsx @@ -1,15 +1,15 @@ import '@testing-library/jest-dom'; import { fireEvent, render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { LifecycleType } from '../../types'; -import { useNFTLifecycleContext } from '../NFTLifecycleProvider'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { LifecycleType } from '../../../../core-react/nft/types'; import { NFTMedia } from './NFTMedia'; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); -vi.mock('../NFTLifecycleProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTLifecycleProvider', () => ({ useNFTLifecycleContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTMedia.tsx b/src/ui/react/nft/view/NFTMedia.tsx index e43928572f..710f5d8bcd 100644 --- a/src/ui/react/nft/view/NFTMedia.tsx +++ b/src/ui/react/nft/view/NFTMedia.tsx @@ -1,8 +1,12 @@ import { useCallback, useMemo } from 'react'; -import { cn } from '../../../../../styles/theme'; -import { LifecycleType, MediaType, type NFTError } from '../../../../../core/nft/types'; -import { useNFTLifecycleContext } from '../NFTLifecycleProvider'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { + LifecycleType, + MediaType, + type NFTError, +} from '../../../../core-react/nft/types'; +import { cn } from '../../../../styles/theme'; import { NFTAudio } from './NFTAudio'; import { NFTImage } from './NFTImage'; import { NFTVideo } from './NFTVideo'; diff --git a/src/ui/react/nft/view/NFTMintDate.test.tsx b/src/ui/react/nft/view/NFTMintDate.test.tsx index 08f6f1ac93..0a6d313207 100644 --- a/src/ui/react/nft/view/NFTMintDate.test.tsx +++ b/src/ui/react/nft/view/NFTMintDate.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTMintDate } from './NFTMintDate'; -vi.mock('../NFTProvider'); +vi.mock('../../../../core-react/nft/providers/NFTProvider'); describe('NFTMintDate', () => { const mockUseNFTContext = useNFTContext as Mock; diff --git a/src/ui/react/nft/view/NFTMintDate.tsx b/src/ui/react/nft/view/NFTMintDate.tsx index 44a63599d6..30253bddca 100644 --- a/src/ui/react/nft/view/NFTMintDate.tsx +++ b/src/ui/react/nft/view/NFTMintDate.tsx @@ -1,6 +1,6 @@ import { type ReactNode, useMemo } from 'react'; -import { cn, color, text } from '../../../../styles/theme'; import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { cn, color, text } from '../../../../styles/theme'; const DATE_OPTIONS = { year: 'numeric', diff --git a/src/ui/react/nft/view/NFTOwner.test.tsx b/src/ui/react/nft/view/NFTOwner.test.tsx index b1490274e0..c4e81942a3 100644 --- a/src/ui/react/nft/view/NFTOwner.test.tsx +++ b/src/ui/react/nft/view/NFTOwner.test.tsx @@ -9,12 +9,12 @@ import { it, vi, } from 'vitest'; -import { useOnchainKit } from '../../../core-react/useOnchainKit'; -import { useNFTContext } from '../NFTProvider'; +import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTOwner } from './NFTOwner'; -vi.mock('../../../core-react/useOnchainKit'); -vi.mock('../NFTProvider'); +vi.mock('../../../../core-react/useOnchainKit'); +vi.mock('../../../../core-react/nft/providers/NFTProvider'); vi.mock('../../../identity', async () => ({ ...(await vi.importActual('../../../identity')), Identity: ({ diff --git a/src/ui/react/nft/view/NFTTitle.test.tsx b/src/ui/react/nft/view/NFTTitle.test.tsx index 5911aa59f2..16f498e9cc 100644 --- a/src/ui/react/nft/view/NFTTitle.test.tsx +++ b/src/ui/react/nft/view/NFTTitle.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../NFTProvider'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { NFTTitle } from './NFTTitle'; -vi.mock('../NFTProvider', () => ({ +vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTTitle.tsx b/src/ui/react/nft/view/NFTTitle.tsx index 36fb081724..b98c632550 100644 --- a/src/ui/react/nft/view/NFTTitle.tsx +++ b/src/ui/react/nft/view/NFTTitle.tsx @@ -1,5 +1,5 @@ -import { cn, text } from '../../../../styles/theme'; import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { cn, text } from '../../../../styles/theme'; type NFTTitleReact = { className?: string; diff --git a/src/ui/react/nft/view/NFTVideo.tsx b/src/ui/react/nft/view/NFTVideo.tsx index ea3010cd15..240af97fbe 100644 --- a/src/ui/react/nft/view/NFTVideo.tsx +++ b/src/ui/react/nft/view/NFTVideo.tsx @@ -1,8 +1,8 @@ import { useEffect, useRef } from 'react'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import type { NFTError } from '../../../../core-react/nft/types'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; -import type { NFTError } from '../../../../core-react/nft/types'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTVideoReact = { className?: string; From 77fc8fadee44f1149874849fa1a6c1a52ce0107c Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Tue, 10 Dec 2024 17:05:17 -0500 Subject: [PATCH 3/9] fix: exports --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a78e5f5ec2..064664b10a 100644 --- a/package.json +++ b/package.json @@ -143,22 +143,22 @@ "default": "./esm/identity/index.js" }, "./nft": { - "types": "./esm/nft/index.d.ts", - "module": "./esm/nft/index.js", - "import": "./esm/nft/index.js", - "default": "./esm/nft/index.js" + "types": "./esm/ui/react/nft/index.d.ts", + "module": "./esm/ui/react/nft/index.js", + "import": "./esm/ui/react/nft/index.js", + "default": "./esm/ui/react/nft/index.js" }, "./nft/view": { - "types": "./esm/nft/components/view/index.d.ts", - "module": "./esm/nft/components/view/index.js", - "import": "./esm/nft/components/view/index.js", - "default": "./esm/nft/components/view/index.js" + "types": "./esm/ui/react/nft/view/index.d.ts", + "module": "./esm/ui/react/nft/view/index.js", + "import": "./esm/ui/react/nft/view/index.js", + "default": "./esm/ui/react/nft/view/index.js" }, "./nft/mint": { - "types": "./esm/nft/components/mint/index.d.ts", - "module": "./esm/nft/components/mint/index.js", - "import": "./esm/nft/components/mint/index.js", - "default": "./esm/nft/components/mint/index.js" + "types": "./esm/ui/react/nft/mint/index.d.ts", + "module": "./esm/ui/react/nft/mint/index.js", + "import": "./esm/ui/react/nft/mint/index.js", + "default": "./esm/ui/react/nft/mint/index.js" }, "./swap": { "types": "./esm/swap/index.d.ts", From dabaa9578959d78d6602674ecce33be34b7db939 Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Thu, 12 Dec 2024 10:21:54 -0500 Subject: [PATCH 4/9] fix: conflict --- src/ui/react/nft/NFTCard.test.tsx | 18 +++--------------- src/ui/react/nft/NFTCard.tsx | 7 ++++++- src/ui/react/nft/NFTMintCard.test.tsx | 17 +++-------------- src/ui/react/nft/NFTMintCard.tsx | 5 ++++- src/ui/react/nft/mint/NFTMintButton.test.tsx | 15 ++------------- src/ui/react/nft/view/NFTOwner.test.tsx | 4 ++-- 6 files changed, 20 insertions(+), 46 deletions(-) diff --git a/src/ui/react/nft/NFTCard.test.tsx b/src/ui/react/nft/NFTCard.test.tsx index 4b2da9f212..4b3d002d76 100644 --- a/src/ui/react/nft/NFTCard.test.tsx +++ b/src/ui/react/nft/NFTCard.test.tsx @@ -10,30 +10,18 @@ import { vi, } from 'vitest'; import { useAccount } from 'wagmi'; -<<<<<<< HEAD -import { useIsMounted } from '../../core-react/internal/hooks/useIsMounted'; -======= import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; -import { useIsMounted } from '../../../useIsMounted'; ->>>>>>> 38ec07ca (fix: lint/tests) +import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; import { NFTCard } from './NFTCard'; vi.mock('wagmi', () => ({ useAccount: vi.fn(), })); -<<<<<<< HEAD -vi.mock('../../core-react/internal/hooks/useTheme', () => ({ +vi.mock('../../../core-react/internal/hooks/useTheme', () => ({ useTheme: vi.fn(() => 'default-light'), })); -vi.mock('../../core-react/internal/hooks/useIsMounted'); -vi.mock('./NFTProvider', () => ({ -======= -vi.mock('../../../useTheme', () => ({ - useTheme: vi.fn(() => 'default-light'), -})); -vi.mock('../../../useIsMounted'); +vi.mock('../../../core-react/internal/hooks/useIsMounted'); vi.mock('../../../core-react/nft/providers/NFTProvider', () => ({ ->>>>>>> 38ec07ca (fix: lint/tests) NFTProvider: vi.fn(({ children }) =>
{children}
), })); diff --git a/src/ui/react/nft/NFTCard.tsx b/src/ui/react/nft/NFTCard.tsx index abae0f87e4..689e1fa0d0 100644 --- a/src/ui/react/nft/NFTCard.tsx +++ b/src/ui/react/nft/NFTCard.tsx @@ -4,8 +4,13 @@ import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; import { useTheme } from '../../../core-react/internal/hooks/useTheme'; import { border, cn, color, pressable } from '../../../styles/theme'; import { useNFTData as defaultUseNFTData } from '../../../core-react/nft/hooks/useNFTData'; -import { LifecycleType, type NFTCardReact } from '../../../core-react/nft/types'; +import { + LifecycleType, + type NFTCardReact, +} from '../../../core-react/nft/types'; import NFTErrorBoundary from './NFTErrorBoundary'; +import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; import { NFTErrorFallback } from './NFTErrorFallback'; export function NFTCard({ diff --git a/src/ui/react/nft/NFTMintCard.test.tsx b/src/ui/react/nft/NFTMintCard.test.tsx index e8ff5f7c9c..a63564952e 100644 --- a/src/ui/react/nft/NFTMintCard.test.tsx +++ b/src/ui/react/nft/NFTMintCard.test.tsx @@ -9,25 +9,14 @@ import { it, vi, } from 'vitest'; -<<<<<<< HEAD -import { useIsMounted } from '../../core-react/internal/hooks/useIsMounted'; +import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; import { NFTMintCard } from './NFTMintCard'; -vi.mock('../../core-react/internal/hooks/useTheme', () => ({ +vi.mock('../../../core-react/internal/hooks/useTheme', () => ({ useTheme: vi.fn(() => 'default-light'), })); -vi.mock('../../core-react/internal/hooks/useIsMounted'); -vi.mock('./NFTProvider', () => ({ -======= -import { useIsMounted } from '../../../useIsMounted'; -import { NFTMintCard } from './NFTMintCard'; - -vi.mock('../../../useTheme', () => ({ - useTheme: vi.fn(() => 'default-light'), -})); -vi.mock('../../../useIsMounted'); +vi.mock('../../../core-react/internal/hooks/useIsMounted'); vi.mock('../../../core-react/nft/providers/NFTProvider', () => ({ ->>>>>>> 38ec07ca (fix: lint/tests) NFTProvider: vi.fn(({ children }) =>
{children}
), })); diff --git a/src/ui/react/nft/NFTMintCard.tsx b/src/ui/react/nft/NFTMintCard.tsx index 70fab1dbd2..a8dda00022 100644 --- a/src/ui/react/nft/NFTMintCard.tsx +++ b/src/ui/react/nft/NFTMintCard.tsx @@ -2,7 +2,10 @@ import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; import { useTheme } from '../../../core-react/internal/hooks/useTheme'; import { background, border, cn, color } from '../../../styles/theme'; import { useMintData as defaultUseMintData } from '../../../core-react/nft/hooks/useMintData'; -import { LifecycleType, type NFTMintCardReact } from '../../../core-react/nft/types'; +import { + LifecycleType, + type NFTMintCardReact, +} from '../../../core-react/nft/types'; import { buildMintTransactionData as defaultBuildMintTransaction } from '../../../core/nft/utils/buildMintTransactionData'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; diff --git a/src/ui/react/nft/mint/NFTMintButton.test.tsx b/src/ui/react/nft/mint/NFTMintButton.test.tsx index 284cb6136e..b980c43e78 100644 --- a/src/ui/react/nft/mint/NFTMintButton.test.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.test.tsx @@ -11,25 +11,14 @@ import { useChainId, } from 'wagmi'; import { mock } from 'wagmi/connectors'; -<<<<<<< HEAD -import { useOnchainKit } from '../../../core-react/useOnchainKit'; -import { useNFTLifecycleContext } from '../NFTLifecycleProvider'; -import { useNFTContext } from '../NFTProvider'; -import { NFTMintButton } from './NFTMintButton'; - -vi.mock('../NFTProvider'); -vi.mock('../NFTLifecycleProvider'); -vi.mock('../../../core-react/useOnchainKit'); -======= import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '../../../../useOnchainKit'; +import { useOnchainKit } from '../../../../core-react/useOnchainKit'; import { NFTMintButton } from './NFTMintButton'; vi.mock('../../../../core-react/nft/providers/NFTProvider'); vi.mock('../../../../core-react/nft/providers/NFTLifecycleProvider'); -vi.mock('../../../../useOnchainKit'); ->>>>>>> 38ec07ca (fix: lint/tests) +vi.mock('../../../../core-react/useOnchainKit'); vi.mock('wagmi', async (importOriginal) => { return { ...(await importOriginal()), diff --git a/src/ui/react/nft/view/NFTOwner.test.tsx b/src/ui/react/nft/view/NFTOwner.test.tsx index c4e81942a3..9ae5bc12f8 100644 --- a/src/ui/react/nft/view/NFTOwner.test.tsx +++ b/src/ui/react/nft/view/NFTOwner.test.tsx @@ -15,8 +15,8 @@ import { NFTOwner } from './NFTOwner'; vi.mock('../../../../core-react/useOnchainKit'); vi.mock('../../../../core-react/nft/providers/NFTProvider'); -vi.mock('../../../identity', async () => ({ - ...(await vi.importActual('../../../identity')), +vi.mock('../../../../identity', async () => ({ + ...(await vi.importActual('../../../../identity')), Identity: ({ className, address, From e7ce06f557faa8cd1ba625f2902b1076b5024297 Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Thu, 12 Dec 2024 10:22:19 -0500 Subject: [PATCH 5/9] fix: lint --- src/ui/react/nft/NFTCard.test.tsx | 2 +- src/ui/react/nft/NFTCard.tsx | 6 +++--- src/ui/react/nft/NFTMintCard.tsx | 6 +++--- src/ui/react/nft/mint/NFTCreator.tsx | 2 +- src/ui/react/nft/mint/NFTMinters.tsx | 2 +- src/ui/react/nft/view/NFTOwner.tsx | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ui/react/nft/NFTCard.test.tsx b/src/ui/react/nft/NFTCard.test.tsx index 4b3d002d76..84e37e0537 100644 --- a/src/ui/react/nft/NFTCard.test.tsx +++ b/src/ui/react/nft/NFTCard.test.tsx @@ -10,8 +10,8 @@ import { vi, } from 'vitest'; import { useAccount } from 'wagmi'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; import { NFTCard } from './NFTCard'; vi.mock('wagmi', () => ({ diff --git a/src/ui/react/nft/NFTCard.tsx b/src/ui/react/nft/NFTCard.tsx index 689e1fa0d0..633ef1d2c6 100644 --- a/src/ui/react/nft/NFTCard.tsx +++ b/src/ui/react/nft/NFTCard.tsx @@ -2,15 +2,15 @@ import { useCallback } from 'react'; import { useAccount } from 'wagmi'; import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; import { useTheme } from '../../../core-react/internal/hooks/useTheme'; -import { border, cn, color, pressable } from '../../../styles/theme'; import { useNFTData as defaultUseNFTData } from '../../../core-react/nft/hooks/useNFTData'; +import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; import { LifecycleType, type NFTCardReact, } from '../../../core-react/nft/types'; +import { border, cn, color, pressable } from '../../../styles/theme'; import NFTErrorBoundary from './NFTErrorBoundary'; -import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; import { NFTErrorFallback } from './NFTErrorFallback'; export function NFTCard({ diff --git a/src/ui/react/nft/NFTMintCard.tsx b/src/ui/react/nft/NFTMintCard.tsx index a8dda00022..0b8c18d36f 100644 --- a/src/ui/react/nft/NFTMintCard.tsx +++ b/src/ui/react/nft/NFTMintCard.tsx @@ -1,16 +1,16 @@ import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; import { useTheme } from '../../../core-react/internal/hooks/useTheme'; -import { background, border, cn, color } from '../../../styles/theme'; import { useMintData as defaultUseMintData } from '../../../core-react/nft/hooks/useMintData'; +import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; import { LifecycleType, type NFTMintCardReact, } from '../../../core-react/nft/types'; import { buildMintTransactionData as defaultBuildMintTransaction } from '../../../core/nft/utils/buildMintTransactionData'; +import { background, border, cn, color } from '../../../styles/theme'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; -import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; export function NFTMintCard({ children, diff --git a/src/ui/react/nft/mint/NFTCreator.tsx b/src/ui/react/nft/mint/NFTCreator.tsx index d4d4b2d8fe..b1196f9e05 100644 --- a/src/ui/react/nft/mint/NFTCreator.tsx +++ b/src/ui/react/nft/mint/NFTCreator.tsx @@ -1,7 +1,7 @@ +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { useOnchainKit } from '../../../../core-react/useOnchainKit'; import { Avatar, Badge, Identity, Name } from '../../../../identity'; import { cn } from '../../../../styles/theme'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTCreatorReact = { className?: string; diff --git a/src/ui/react/nft/mint/NFTMinters.tsx b/src/ui/react/nft/mint/NFTMinters.tsx index 300f894e65..54b68a62e0 100644 --- a/src/ui/react/nft/mint/NFTMinters.tsx +++ b/src/ui/react/nft/mint/NFTMinters.tsx @@ -1,7 +1,7 @@ +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { useOnchainKit } from '../../../../core-react/useOnchainKit'; import { Avatar, Identity, Name } from '../../../../identity'; import { cn, color, text } from '../../../../styles/theme'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTMintersReact = { className?: string; diff --git a/src/ui/react/nft/view/NFTOwner.tsx b/src/ui/react/nft/view/NFTOwner.tsx index 03fc16463c..8893265d63 100644 --- a/src/ui/react/nft/view/NFTOwner.tsx +++ b/src/ui/react/nft/view/NFTOwner.tsx @@ -1,8 +1,8 @@ import type { ReactNode } from 'react'; +import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; import { useOnchainKit } from '../../../../core-react/useOnchainKit'; import { Avatar, Badge, Identity, Name } from '../../../../identity'; import { cn, color, text } from '../../../../styles/theme'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; type NFTOwnerReact = { className?: string; From 2d17dafa5d2bf82b8e38e4d8bc64249fc9974f8d Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Fri, 13 Dec 2024 12:17:31 -0500 Subject: [PATCH 6/9] fix: aliases --- .../nextjs-app-router/onchainkit/package.json | 26 +++++++++---------- src/ui/react/nft/NFTCard.test.tsx | 10 +++---- src/ui/react/nft/NFTCard.tsx | 12 ++++----- src/ui/react/nft/NFTCardDefault.tsx | 2 +- src/ui/react/nft/NFTErrorFallback.test.tsx | 4 +-- src/ui/react/nft/NFTErrorFallback.tsx | 2 +- src/ui/react/nft/NFTMintCard.test.tsx | 8 +++--- src/ui/react/nft/NFTMintCard.tsx | 14 +++++----- src/ui/react/nft/NFTMintCardDefault.tsx | 2 +- src/ui/react/nft/index.ts | 2 +- src/ui/react/nft/mint/NFTAssetCost.test.tsx | 4 +-- src/ui/react/nft/mint/NFTAssetCost.tsx | 4 +-- .../nft/mint/NFTCollectionTitle.test.tsx | 4 +-- src/ui/react/nft/mint/NFTCollectionTitle.tsx | 2 +- src/ui/react/nft/mint/NFTCreator.test.tsx | 8 +++--- src/ui/react/nft/mint/NFTCreator.tsx | 4 +-- src/ui/react/nft/mint/NFTMintButton.test.tsx | 12 ++++----- src/ui/react/nft/mint/NFTMintButton.tsx | 4 +-- src/ui/react/nft/mint/NFTMinters.test.tsx | 4 +-- src/ui/react/nft/mint/NFTMinters.tsx | 4 +-- .../nft/mint/NFTQuantitySelector.test.tsx | 4 +-- src/ui/react/nft/mint/NFTQuantitySelector.tsx | 2 +- src/ui/react/nft/mint/NFTTotalCost.test.tsx | 4 +-- src/ui/react/nft/mint/NFTTotalCost.tsx | 4 +-- src/ui/react/nft/view/NFTAudio.test.tsx | 4 +-- src/ui/react/nft/view/NFTAudio.tsx | 4 +-- src/ui/react/nft/view/NFTImage.test.tsx | 4 +-- src/ui/react/nft/view/NFTImage.tsx | 4 +-- .../react/nft/view/NFTLastSoldPrice.test.tsx | 4 +-- src/ui/react/nft/view/NFTLastSoldPrice.tsx | 2 +- src/ui/react/nft/view/NFTMedia.test.tsx | 10 +++---- src/ui/react/nft/view/NFTMedia.tsx | 6 ++--- src/ui/react/nft/view/NFTMintDate.test.tsx | 4 +-- src/ui/react/nft/view/NFTMintDate.tsx | 2 +- src/ui/react/nft/view/NFTOwner.test.tsx | 8 +++--- src/ui/react/nft/view/NFTOwner.tsx | 4 +-- src/ui/react/nft/view/NFTTitle.test.tsx | 4 +-- src/ui/react/nft/view/NFTTitle.tsx | 2 +- src/ui/react/nft/view/NFTVideo.test.tsx | 4 +-- src/ui/react/nft/view/NFTVideo.tsx | 4 +-- 40 files changed, 108 insertions(+), 108 deletions(-) diff --git a/playground/nextjs-app-router/onchainkit/package.json b/playground/nextjs-app-router/onchainkit/package.json index 6ea8b9d2ef..064664b10a 100644 --- a/playground/nextjs-app-router/onchainkit/package.json +++ b/playground/nextjs-app-router/onchainkit/package.json @@ -1,6 +1,6 @@ { "name": "@coinbase/onchainkit", - "version": "0.35.8", + "version": "0.36.0", "type": "module", "repository": "https://github.com/coinbase/onchainkit.git", "license": "MIT", @@ -143,22 +143,22 @@ "default": "./esm/identity/index.js" }, "./nft": { - "types": "./esm/nft/index.d.ts", - "module": "./esm/nft/index.js", - "import": "./esm/nft/index.js", - "default": "./esm/nft/index.js" + "types": "./esm/ui/react/nft/index.d.ts", + "module": "./esm/ui/react/nft/index.js", + "import": "./esm/ui/react/nft/index.js", + "default": "./esm/ui/react/nft/index.js" }, "./nft/view": { - "types": "./esm/nft/components/view/index.d.ts", - "module": "./esm/nft/components/view/index.js", - "import": "./esm/nft/components/view/index.js", - "default": "./esm/nft/components/view/index.js" + "types": "./esm/ui/react/nft/view/index.d.ts", + "module": "./esm/ui/react/nft/view/index.js", + "import": "./esm/ui/react/nft/view/index.js", + "default": "./esm/ui/react/nft/view/index.js" }, "./nft/mint": { - "types": "./esm/nft/components/mint/index.d.ts", - "module": "./esm/nft/components/mint/index.js", - "import": "./esm/nft/components/mint/index.js", - "default": "./esm/nft/components/mint/index.js" + "types": "./esm/ui/react/nft/mint/index.d.ts", + "module": "./esm/ui/react/nft/mint/index.js", + "import": "./esm/ui/react/nft/mint/index.js", + "default": "./esm/ui/react/nft/mint/index.js" }, "./swap": { "types": "./esm/swap/index.d.ts", diff --git a/src/ui/react/nft/NFTCard.test.tsx b/src/ui/react/nft/NFTCard.test.tsx index 84e37e0537..3fe2a9cbca 100644 --- a/src/ui/react/nft/NFTCard.test.tsx +++ b/src/ui/react/nft/NFTCard.test.tsx @@ -10,18 +10,18 @@ import { vi, } from 'vitest'; import { useAccount } from 'wagmi'; -import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; +import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; +import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; import { NFTCard } from './NFTCard'; vi.mock('wagmi', () => ({ useAccount: vi.fn(), })); -vi.mock('../../../core-react/internal/hooks/useTheme', () => ({ +vi.mock('@/core-react/internal/hooks/useTheme', () => ({ useTheme: vi.fn(() => 'default-light'), })); -vi.mock('../../../core-react/internal/hooks/useIsMounted'); -vi.mock('../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/internal/hooks/useIsMounted'); +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ NFTProvider: vi.fn(({ children }) =>
{children}
), })); diff --git a/src/ui/react/nft/NFTCard.tsx b/src/ui/react/nft/NFTCard.tsx index 633ef1d2c6..4c789e2127 100644 --- a/src/ui/react/nft/NFTCard.tsx +++ b/src/ui/react/nft/NFTCard.tsx @@ -1,14 +1,14 @@ import { useCallback } from 'react'; import { useAccount } from 'wagmi'; -import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; -import { useTheme } from '../../../core-react/internal/hooks/useTheme'; -import { useNFTData as defaultUseNFTData } from '../../../core-react/nft/hooks/useNFTData'; -import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; +import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; +import { useTheme } from '@/core-react/internal/hooks/useTheme'; +import { useNFTData as defaultUseNFTData } from '@/core-react/nft/hooks/useNFTData'; +import { NFTLifecycleProvider } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; import { LifecycleType, type NFTCardReact, -} from '../../../core-react/nft/types'; +} from '@/core-react/nft/types'; import { border, cn, color, pressable } from '../../../styles/theme'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; diff --git a/src/ui/react/nft/NFTCardDefault.tsx b/src/ui/react/nft/NFTCardDefault.tsx index b44f8787d2..ab993382e6 100644 --- a/src/ui/react/nft/NFTCardDefault.tsx +++ b/src/ui/react/nft/NFTCardDefault.tsx @@ -1,4 +1,4 @@ -import type { NFTCardDefaultReact } from '../../../core-react/nft/types'; +import type { NFTCardDefaultReact } from '@/core-react/nft/types'; import { NFTCard } from './NFTCard'; import { NFTLastSoldPrice, diff --git a/src/ui/react/nft/NFTErrorFallback.test.tsx b/src/ui/react/nft/NFTErrorFallback.test.tsx index fe5449d330..f6e4f943fd 100644 --- a/src/ui/react/nft/NFTErrorFallback.test.tsx +++ b/src/ui/react/nft/NFTErrorFallback.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useTheme } from '../../../core-react/internal/hooks/useTheme'; +import { useTheme } from '@/core-react/internal/hooks/useTheme'; import { NFTErrorFallback } from './NFTErrorFallback'; -vi.mock('../../../core-react/internal/hooks/useTheme'); +vi.mock('@/core-react/internal/hooks/useTheme'); describe('NFTErrorFallback', () => { beforeEach(() => { diff --git a/src/ui/react/nft/NFTErrorFallback.tsx b/src/ui/react/nft/NFTErrorFallback.tsx index d3df65efd2..5b1f546981 100644 --- a/src/ui/react/nft/NFTErrorFallback.tsx +++ b/src/ui/react/nft/NFTErrorFallback.tsx @@ -1,4 +1,4 @@ -import { useTheme } from '../../../core-react/internal/hooks/useTheme'; +import { useTheme } from '@/core-react/internal/hooks/useTheme'; import { background, border, cn, color } from '../../../styles/theme'; export function NFTErrorFallback({ error }: { error: Error }) { diff --git a/src/ui/react/nft/NFTMintCard.test.tsx b/src/ui/react/nft/NFTMintCard.test.tsx index a63564952e..ee4c421cd3 100644 --- a/src/ui/react/nft/NFTMintCard.test.tsx +++ b/src/ui/react/nft/NFTMintCard.test.tsx @@ -9,14 +9,14 @@ import { it, vi, } from 'vitest'; -import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; +import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; import { NFTMintCard } from './NFTMintCard'; -vi.mock('../../../core-react/internal/hooks/useTheme', () => ({ +vi.mock('@/core-react/internal/hooks/useTheme', () => ({ useTheme: vi.fn(() => 'default-light'), })); -vi.mock('../../../core-react/internal/hooks/useIsMounted'); -vi.mock('../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/internal/hooks/useIsMounted'); +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ NFTProvider: vi.fn(({ children }) =>
{children}
), })); diff --git a/src/ui/react/nft/NFTMintCard.tsx b/src/ui/react/nft/NFTMintCard.tsx index 0b8c18d36f..446a91df35 100644 --- a/src/ui/react/nft/NFTMintCard.tsx +++ b/src/ui/react/nft/NFTMintCard.tsx @@ -1,13 +1,13 @@ -import { useIsMounted } from '../../../core-react/internal/hooks/useIsMounted'; -import { useTheme } from '../../../core-react/internal/hooks/useTheme'; -import { useMintData as defaultUseMintData } from '../../../core-react/nft/hooks/useMintData'; -import { NFTLifecycleProvider } from '../../../core-react/nft/providers/NFTLifecycleProvider'; -import { NFTProvider } from '../../../core-react/nft/providers/NFTProvider'; +import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; +import { useTheme } from '@/core-react/internal/hooks/useTheme'; +import { useMintData as defaultUseMintData } from '@/core-react/nft/hooks/useMintData'; +import { NFTLifecycleProvider } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; import { LifecycleType, type NFTMintCardReact, -} from '../../../core-react/nft/types'; -import { buildMintTransactionData as defaultBuildMintTransaction } from '../../../core/nft/utils/buildMintTransactionData'; +} from '@/core-react/nft/types'; +import { buildMintTransactionData as defaultBuildMintTransaction } from '@/core/nft/utils/buildMintTransactionData'; import { background, border, cn, color } from '../../../styles/theme'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; diff --git a/src/ui/react/nft/NFTMintCardDefault.tsx b/src/ui/react/nft/NFTMintCardDefault.tsx index 74ecc139f3..1e743850cd 100644 --- a/src/ui/react/nft/NFTMintCardDefault.tsx +++ b/src/ui/react/nft/NFTMintCardDefault.tsx @@ -1,4 +1,4 @@ -import type { NFTMintCardDefaultReact } from '../../../core-react/nft/types'; +import type { NFTMintCardDefaultReact } from '@/core-react/nft/types'; import { NFTMintCard } from './NFTMintCard'; import { NFTAssetCost, diff --git a/src/ui/react/nft/index.ts b/src/ui/react/nft/index.ts index 55407eaad5..bab84bc955 100644 --- a/src/ui/react/nft/index.ts +++ b/src/ui/react/nft/index.ts @@ -13,4 +13,4 @@ export type { NFTMintCardReact, NFTMintCardDefaultReact, UseNFTData, -} from '../../../core-react/nft/types'; +} from '@/core-react/nft/types'; diff --git a/src/ui/react/nft/mint/NFTAssetCost.test.tsx b/src/ui/react/nft/mint/NFTAssetCost.test.tsx index 69f0775d04..fc22e1e114 100644 --- a/src/ui/react/nft/mint/NFTAssetCost.test.tsx +++ b/src/ui/react/nft/mint/NFTAssetCost.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTAssetCost } from './NFTAssetCost'; -vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/nft/providers/NFTProvider'); describe('NFTAssetCost', () => { const mockUseNFTContext = useNFTContext as Mock; diff --git a/src/ui/react/nft/mint/NFTAssetCost.tsx b/src/ui/react/nft/mint/NFTAssetCost.tsx index 47d01a267b..d315432b9d 100644 --- a/src/ui/react/nft/mint/NFTAssetCost.tsx +++ b/src/ui/react/nft/mint/NFTAssetCost.tsx @@ -1,5 +1,5 @@ -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { multiplyFloats } from '../../../../core/utils/multiplyFloats'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { multiplyFloats } from '@/core/utils/multiplyFloats'; import { cn, text } from '../../../../styles/theme'; import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; import { formatAmount } from '../../../../token/utils/formatAmount'; diff --git a/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx index 4e07fcba06..08ba52a706 100644 --- a/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx +++ b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTCollectionTitle } from './NFTCollectionTitle'; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/mint/NFTCollectionTitle.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.tsx index d796e00290..fb09aea31d 100644 --- a/src/ui/react/nft/mint/NFTCollectionTitle.tsx +++ b/src/ui/react/nft/mint/NFTCollectionTitle.tsx @@ -1,4 +1,4 @@ -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { cn, text } from '../../../../styles/theme'; type NFTCollectionTitleReact = { diff --git a/src/ui/react/nft/mint/NFTCreator.test.tsx b/src/ui/react/nft/mint/NFTCreator.test.tsx index 4e716b147c..39120059e2 100644 --- a/src/ui/react/nft/mint/NFTCreator.test.tsx +++ b/src/ui/react/nft/mint/NFTCreator.test.tsx @@ -1,14 +1,14 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { NFTCreator } from './NFTCreator'; -vi.mock('../../../../core-react/useOnchainKit', () => ({ +vi.mock('@/core-react/useOnchainKit', () => ({ useOnchainKit: vi.fn(), })); -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/mint/NFTCreator.tsx b/src/ui/react/nft/mint/NFTCreator.tsx index b1196f9e05..077f72ddf4 100644 --- a/src/ui/react/nft/mint/NFTCreator.tsx +++ b/src/ui/react/nft/mint/NFTCreator.tsx @@ -1,5 +1,5 @@ -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { Avatar, Badge, Identity, Name } from '../../../../identity'; import { cn } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/mint/NFTMintButton.test.tsx b/src/ui/react/nft/mint/NFTMintButton.test.tsx index b980c43e78..6c00be1b1d 100644 --- a/src/ui/react/nft/mint/NFTMintButton.test.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.test.tsx @@ -11,14 +11,14 @@ import { useChainId, } from 'wagmi'; import { mock } from 'wagmi/connectors'; -import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { NFTMintButton } from './NFTMintButton'; -vi.mock('../../../../core-react/nft/providers/NFTProvider'); -vi.mock('../../../../core-react/nft/providers/NFTLifecycleProvider'); -vi.mock('../../../../core-react/useOnchainKit'); +vi.mock('@/core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/nft/providers/NFTLifecycleProvider'); +vi.mock('@/core-react/useOnchainKit'); vi.mock('wagmi', async (importOriginal) => { return { ...(await importOriginal()), diff --git a/src/ui/react/nft/mint/NFTMintButton.tsx b/src/ui/react/nft/mint/NFTMintButton.tsx index 365c149af5..d48da1a2a6 100644 --- a/src/ui/react/nft/mint/NFTMintButton.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useAccount, useChainId } from 'wagmi'; -import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { Spinner } from '../../../../internal/components/Spinner'; import { cn, color, text } from '../../../../styles/theme'; import { diff --git a/src/ui/react/nft/mint/NFTMinters.test.tsx b/src/ui/react/nft/mint/NFTMinters.test.tsx index 5fa1b64dbe..b3503741aa 100644 --- a/src/ui/react/nft/mint/NFTMinters.test.tsx +++ b/src/ui/react/nft/mint/NFTMinters.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTMinters } from './NFTMinters'; -vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/nft/providers/NFTProvider'); vi.mock('../../../../identity', async () => ({ ...(await vi.importActual('../../../../identity')), diff --git a/src/ui/react/nft/mint/NFTMinters.tsx b/src/ui/react/nft/mint/NFTMinters.tsx index 54b68a62e0..cdafa15270 100644 --- a/src/ui/react/nft/mint/NFTMinters.tsx +++ b/src/ui/react/nft/mint/NFTMinters.tsx @@ -1,5 +1,5 @@ -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { Avatar, Identity, Name } from '../../../../identity'; import { cn, color, text } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx index ca7dc433e5..61820ccc81 100644 --- a/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx +++ b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx @@ -10,10 +10,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTQuantitySelector } from './NFTQuantitySelector'; -vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/nft/providers/NFTProvider'); vi.mock('../../../../internal/components/QuantitySelector', () => ({ QuantitySelector: ({ diff --git a/src/ui/react/nft/mint/NFTQuantitySelector.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.tsx index c636e026be..77e2289fed 100644 --- a/src/ui/react/nft/mint/NFTQuantitySelector.tsx +++ b/src/ui/react/nft/mint/NFTQuantitySelector.tsx @@ -1,4 +1,4 @@ -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { QuantitySelector } from '../../../../internal/components/QuantitySelector'; import { cn } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/mint/NFTTotalCost.test.tsx b/src/ui/react/nft/mint/NFTTotalCost.test.tsx index 6016cf3d50..c74ff6f9b6 100644 --- a/src/ui/react/nft/mint/NFTTotalCost.test.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTTotalCost } from './NFTTotalCost'; -vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/nft/providers/NFTProvider'); describe('NFTTotalCost', () => { const mockUseNFTContext = useNFTContext as Mock; diff --git a/src/ui/react/nft/mint/NFTTotalCost.tsx b/src/ui/react/nft/mint/NFTTotalCost.tsx index 2376807f00..2dcae017fd 100644 --- a/src/ui/react/nft/mint/NFTTotalCost.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.tsx @@ -1,6 +1,6 @@ import { type ReactNode, useCallback, useMemo, useState } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { multiplyFloats } from '../../../../core/utils/multiplyFloats'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { multiplyFloats } from '@/core/utils/multiplyFloats'; import { infoSvg } from '../../../../internal/svg/infoSvg'; import { background, border, cn, text } from '../../../../styles/theme'; import { formatAmount } from '../../../../token/utils/formatAmount'; diff --git a/src/ui/react/nft/view/NFTAudio.test.tsx b/src/ui/react/nft/view/NFTAudio.test.tsx index 4a5bd2c52d..0f976e35ee 100644 --- a/src/ui/react/nft/view/NFTAudio.test.tsx +++ b/src/ui/react/nft/view/NFTAudio.test.tsx @@ -9,12 +9,12 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTAudio } from './NFTAudio'; const mockAnimationUrl = 'https://example.com/audio.mp3'; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTAudio.tsx b/src/ui/react/nft/view/NFTAudio.tsx index 861065912e..df3e001e2b 100644 --- a/src/ui/react/nft/view/NFTAudio.tsx +++ b/src/ui/react/nft/view/NFTAudio.tsx @@ -5,8 +5,8 @@ import { useRef, useState, } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import type { NFTError } from '../../../../core-react/nft/types'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import type { NFTError } from '@/core-react/nft/types'; import { background, cn } from '../../../../styles/theme'; type NFTAudioReact = { diff --git a/src/ui/react/nft/view/NFTImage.test.tsx b/src/ui/react/nft/view/NFTImage.test.tsx index 7e43e2f894..027341f794 100644 --- a/src/ui/react/nft/view/NFTImage.test.tsx +++ b/src/ui/react/nft/view/NFTImage.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; import { fireEvent, render, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTImage } from './NFTImage'; const mockContext = { @@ -9,7 +9,7 @@ const mockContext = { description: 'Test NFT Image', }; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTImage.tsx b/src/ui/react/nft/view/NFTImage.tsx index 3ec0d7c941..4093e823a4 100644 --- a/src/ui/react/nft/view/NFTImage.tsx +++ b/src/ui/react/nft/view/NFTImage.tsx @@ -1,6 +1,6 @@ import { type MouseEvent, useCallback, useEffect, useState } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import type { NFTError } from '../../../../core-react/nft/types'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import type { NFTError } from '@/core-react/nft/types'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx index 822eed0c92..3fdf99b05c 100644 --- a/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTLastSoldPrice } from './NFTLastSoldPrice'; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTLastSoldPrice.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.tsx index 12901ce27a..76701fac11 100644 --- a/src/ui/react/nft/view/NFTLastSoldPrice.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { cn, color, text } from '../../../../styles/theme'; import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; import { formatAmount } from '../../../../token/utils/formatAmount'; diff --git a/src/ui/react/nft/view/NFTMedia.test.tsx b/src/ui/react/nft/view/NFTMedia.test.tsx index f06ead4d16..56fbfd4ad6 100644 --- a/src/ui/react/nft/view/NFTMedia.test.tsx +++ b/src/ui/react/nft/view/NFTMedia.test.tsx @@ -1,15 +1,15 @@ import '@testing-library/jest-dom'; import { fireEvent, render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { LifecycleType } from '../../../../core-react/nft/types'; +import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { LifecycleType } from '@/core-react/nft/types'; import { NFTMedia } from './NFTMedia'; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); -vi.mock('../../../../core-react/nft/providers/NFTLifecycleProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTLifecycleProvider', () => ({ useNFTLifecycleContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTMedia.tsx b/src/ui/react/nft/view/NFTMedia.tsx index 710f5d8bcd..46426930bd 100644 --- a/src/ui/react/nft/view/NFTMedia.tsx +++ b/src/ui/react/nft/view/NFTMedia.tsx @@ -1,11 +1,11 @@ import { useCallback, useMemo } from 'react'; -import { useNFTLifecycleContext } from '../../../../core-react/nft/providers/NFTLifecycleProvider'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { LifecycleType, MediaType, type NFTError, -} from '../../../../core-react/nft/types'; +} from '@/core-react/nft/types'; import { cn } from '../../../../styles/theme'; import { NFTAudio } from './NFTAudio'; import { NFTImage } from './NFTImage'; diff --git a/src/ui/react/nft/view/NFTMintDate.test.tsx b/src/ui/react/nft/view/NFTMintDate.test.tsx index 0a6d313207..328e3f1e9f 100644 --- a/src/ui/react/nft/view/NFTMintDate.test.tsx +++ b/src/ui/react/nft/view/NFTMintDate.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTMintDate } from './NFTMintDate'; -vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/nft/providers/NFTProvider'); describe('NFTMintDate', () => { const mockUseNFTContext = useNFTContext as Mock; diff --git a/src/ui/react/nft/view/NFTMintDate.tsx b/src/ui/react/nft/view/NFTMintDate.tsx index 30253bddca..a43be0a6d6 100644 --- a/src/ui/react/nft/view/NFTMintDate.tsx +++ b/src/ui/react/nft/view/NFTMintDate.tsx @@ -1,5 +1,5 @@ import { type ReactNode, useMemo } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { cn, color, text } from '../../../../styles/theme'; const DATE_OPTIONS = { diff --git a/src/ui/react/nft/view/NFTOwner.test.tsx b/src/ui/react/nft/view/NFTOwner.test.tsx index 9ae5bc12f8..8ecc1d166f 100644 --- a/src/ui/react/nft/view/NFTOwner.test.tsx +++ b/src/ui/react/nft/view/NFTOwner.test.tsx @@ -9,12 +9,12 @@ import { it, vi, } from 'vitest'; -import { useOnchainKit } from '../../../../core-react/useOnchainKit'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTOwner } from './NFTOwner'; -vi.mock('../../../../core-react/useOnchainKit'); -vi.mock('../../../../core-react/nft/providers/NFTProvider'); +vi.mock('@/core-react/useOnchainKit'); +vi.mock('@/core-react/nft/providers/NFTProvider'); vi.mock('../../../../identity', async () => ({ ...(await vi.importActual('../../../../identity')), Identity: ({ diff --git a/src/ui/react/nft/view/NFTOwner.tsx b/src/ui/react/nft/view/NFTOwner.tsx index 8893265d63..4cee201a7b 100644 --- a/src/ui/react/nft/view/NFTOwner.tsx +++ b/src/ui/react/nft/view/NFTOwner.tsx @@ -1,6 +1,6 @@ import type { ReactNode } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '../../../../core-react/useOnchainKit'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { Avatar, Badge, Identity, Name } from '../../../../identity'; import { cn, color, text } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/view/NFTTitle.test.tsx b/src/ui/react/nft/view/NFTTitle.test.tsx index 16f498e9cc..6ac1228112 100644 --- a/src/ui/react/nft/view/NFTTitle.test.tsx +++ b/src/ui/react/nft/view/NFTTitle.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTTitle } from './NFTTitle'; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTTitle.tsx b/src/ui/react/nft/view/NFTTitle.tsx index b98c632550..9b5be80211 100644 --- a/src/ui/react/nft/view/NFTTitle.tsx +++ b/src/ui/react/nft/view/NFTTitle.tsx @@ -1,4 +1,4 @@ -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { cn, text } from '../../../../styles/theme'; type NFTTitleReact = { diff --git a/src/ui/react/nft/view/NFTVideo.test.tsx b/src/ui/react/nft/view/NFTVideo.test.tsx index 6f02e3e2fe..7b2df2611f 100644 --- a/src/ui/react/nft/view/NFTVideo.test.tsx +++ b/src/ui/react/nft/view/NFTVideo.test.tsx @@ -9,10 +9,10 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTVideo } from './NFTVideo'; -vi.mock('../../../../core-react/nft/providers/NFTProvider', () => ({ +vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ useNFTContext: vi.fn(), })); diff --git a/src/ui/react/nft/view/NFTVideo.tsx b/src/ui/react/nft/view/NFTVideo.tsx index 240af97fbe..3ea75869c7 100644 --- a/src/ui/react/nft/view/NFTVideo.tsx +++ b/src/ui/react/nft/view/NFTVideo.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef } from 'react'; -import { useNFTContext } from '../../../../core-react/nft/providers/NFTProvider'; -import type { NFTError } from '../../../../core-react/nft/types'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import type { NFTError } from '@/core-react/nft/types'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; From a84b19443204a57e287a4c795abc99b430aa9bef Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Fri, 13 Dec 2024 12:17:46 -0500 Subject: [PATCH 7/9] fix: lint --- src/ui/react/nft/NFTCard.test.tsx | 4 ++-- src/ui/react/nft/NFTCard.tsx | 9 +++------ src/ui/react/nft/NFTErrorFallback.test.tsx | 2 +- src/ui/react/nft/NFTMintCard.test.tsx | 2 +- src/ui/react/nft/NFTMintCard.tsx | 5 +---- src/ui/react/nft/mint/NFTAssetCost.test.tsx | 2 +- src/ui/react/nft/mint/NFTCollectionTitle.test.tsx | 2 +- src/ui/react/nft/mint/NFTCreator.test.tsx | 4 ++-- src/ui/react/nft/mint/NFTMintButton.test.tsx | 6 +++--- src/ui/react/nft/mint/NFTMintButton.tsx | 4 ++-- src/ui/react/nft/mint/NFTMinters.test.tsx | 2 +- src/ui/react/nft/mint/NFTQuantitySelector.test.tsx | 2 +- src/ui/react/nft/mint/NFTTotalCost.test.tsx | 2 +- src/ui/react/nft/mint/NFTTotalCost.tsx | 2 +- src/ui/react/nft/view/NFTAudio.test.tsx | 2 +- src/ui/react/nft/view/NFTAudio.tsx | 4 ++-- src/ui/react/nft/view/NFTImage.test.tsx | 2 +- src/ui/react/nft/view/NFTImage.tsx | 2 +- src/ui/react/nft/view/NFTLastSoldPrice.test.tsx | 2 +- src/ui/react/nft/view/NFTLastSoldPrice.tsx | 2 +- src/ui/react/nft/view/NFTMedia.test.tsx | 4 ++-- src/ui/react/nft/view/NFTMedia.tsx | 2 +- src/ui/react/nft/view/NFTMintDate.test.tsx | 2 +- src/ui/react/nft/view/NFTMintDate.tsx | 2 +- src/ui/react/nft/view/NFTOwner.test.tsx | 4 ++-- src/ui/react/nft/view/NFTOwner.tsx | 2 +- src/ui/react/nft/view/NFTTitle.test.tsx | 2 +- src/ui/react/nft/view/NFTVideo.test.tsx | 2 +- src/ui/react/nft/view/NFTVideo.tsx | 2 +- 29 files changed, 39 insertions(+), 45 deletions(-) diff --git a/src/ui/react/nft/NFTCard.test.tsx b/src/ui/react/nft/NFTCard.test.tsx index 3fe2a9cbca..dc94a8b36c 100644 --- a/src/ui/react/nft/NFTCard.test.tsx +++ b/src/ui/react/nft/NFTCard.test.tsx @@ -1,4 +1,6 @@ import '@testing-library/jest-dom'; +import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; +import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, @@ -10,8 +12,6 @@ import { vi, } from 'vitest'; import { useAccount } from 'wagmi'; -import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; -import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; import { NFTCard } from './NFTCard'; vi.mock('wagmi', () => ({ diff --git a/src/ui/react/nft/NFTCard.tsx b/src/ui/react/nft/NFTCard.tsx index 4c789e2127..e7063fecf7 100644 --- a/src/ui/react/nft/NFTCard.tsx +++ b/src/ui/react/nft/NFTCard.tsx @@ -1,14 +1,11 @@ -import { useCallback } from 'react'; -import { useAccount } from 'wagmi'; import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; import { useTheme } from '@/core-react/internal/hooks/useTheme'; import { useNFTData as defaultUseNFTData } from '@/core-react/nft/hooks/useNFTData'; import { NFTLifecycleProvider } from '@/core-react/nft/providers/NFTLifecycleProvider'; import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; -import { - LifecycleType, - type NFTCardReact, -} from '@/core-react/nft/types'; +import { LifecycleType, type NFTCardReact } from '@/core-react/nft/types'; +import { useCallback } from 'react'; +import { useAccount } from 'wagmi'; import { border, cn, color, pressable } from '../../../styles/theme'; import NFTErrorBoundary from './NFTErrorBoundary'; import { NFTErrorFallback } from './NFTErrorFallback'; diff --git a/src/ui/react/nft/NFTErrorFallback.test.tsx b/src/ui/react/nft/NFTErrorFallback.test.tsx index f6e4f943fd..ea7fba8622 100644 --- a/src/ui/react/nft/NFTErrorFallback.test.tsx +++ b/src/ui/react/nft/NFTErrorFallback.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; +import { useTheme } from '@/core-react/internal/hooks/useTheme'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useTheme } from '@/core-react/internal/hooks/useTheme'; import { NFTErrorFallback } from './NFTErrorFallback'; vi.mock('@/core-react/internal/hooks/useTheme'); diff --git a/src/ui/react/nft/NFTMintCard.test.tsx b/src/ui/react/nft/NFTMintCard.test.tsx index ee4c421cd3..c8d50343fa 100644 --- a/src/ui/react/nft/NFTMintCard.test.tsx +++ b/src/ui/react/nft/NFTMintCard.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; import { render } from '@testing-library/react'; import { type Mock, @@ -9,7 +10,6 @@ import { it, vi, } from 'vitest'; -import { useIsMounted } from '@/core-react/internal/hooks/useIsMounted'; import { NFTMintCard } from './NFTMintCard'; vi.mock('@/core-react/internal/hooks/useTheme', () => ({ diff --git a/src/ui/react/nft/NFTMintCard.tsx b/src/ui/react/nft/NFTMintCard.tsx index 446a91df35..244162c161 100644 --- a/src/ui/react/nft/NFTMintCard.tsx +++ b/src/ui/react/nft/NFTMintCard.tsx @@ -3,10 +3,7 @@ import { useTheme } from '@/core-react/internal/hooks/useTheme'; import { useMintData as defaultUseMintData } from '@/core-react/nft/hooks/useMintData'; import { NFTLifecycleProvider } from '@/core-react/nft/providers/NFTLifecycleProvider'; import { NFTProvider } from '@/core-react/nft/providers/NFTProvider'; -import { - LifecycleType, - type NFTMintCardReact, -} from '@/core-react/nft/types'; +import { LifecycleType, type NFTMintCardReact } from '@/core-react/nft/types'; import { buildMintTransactionData as defaultBuildMintTransaction } from '@/core/nft/utils/buildMintTransactionData'; import { background, border, cn, color } from '../../../styles/theme'; import NFTErrorBoundary from './NFTErrorBoundary'; diff --git a/src/ui/react/nft/mint/NFTAssetCost.test.tsx b/src/ui/react/nft/mint/NFTAssetCost.test.tsx index fc22e1e114..d5ba9132ba 100644 --- a/src/ui/react/nft/mint/NFTAssetCost.test.tsx +++ b/src/ui/react/nft/mint/NFTAssetCost.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, @@ -9,7 +10,6 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTAssetCost } from './NFTAssetCost'; vi.mock('@/core-react/nft/providers/NFTProvider'); diff --git a/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx index 08ba52a706..8acc5d0822 100644 --- a/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx +++ b/src/ui/react/nft/mint/NFTCollectionTitle.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTCollectionTitle } from './NFTCollectionTitle'; vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ diff --git a/src/ui/react/nft/mint/NFTCreator.test.tsx b/src/ui/react/nft/mint/NFTCreator.test.tsx index 39120059e2..9ad7de175f 100644 --- a/src/ui/react/nft/mint/NFTCreator.test.tsx +++ b/src/ui/react/nft/mint/NFTCreator.test.tsx @@ -1,8 +1,8 @@ import '@testing-library/jest-dom'; -import { render } from '@testing-library/react'; -import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { useOnchainKit } from '@/core-react/useOnchainKit'; +import { render } from '@testing-library/react'; +import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; import { NFTCreator } from './NFTCreator'; vi.mock('@/core-react/useOnchainKit', () => ({ diff --git a/src/ui/react/nft/mint/NFTMintButton.test.tsx b/src/ui/react/nft/mint/NFTMintButton.test.tsx index 6c00be1b1d..1ece57b03e 100644 --- a/src/ui/react/nft/mint/NFTMintButton.test.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.test.tsx @@ -1,5 +1,8 @@ import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; +import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { base } from 'viem/chains'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; @@ -11,9 +14,6 @@ import { useChainId, } from 'wagmi'; import { mock } from 'wagmi/connectors'; -import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; -import { useOnchainKit } from '@/core-react/useOnchainKit'; import { NFTMintButton } from './NFTMintButton'; vi.mock('@/core-react/nft/providers/NFTProvider'); diff --git a/src/ui/react/nft/mint/NFTMintButton.tsx b/src/ui/react/nft/mint/NFTMintButton.tsx index d48da1a2a6..a79e173fe5 100644 --- a/src/ui/react/nft/mint/NFTMintButton.tsx +++ b/src/ui/react/nft/mint/NFTMintButton.tsx @@ -1,7 +1,7 @@ -import { useCallback, useEffect, useMemo, useState } from 'react'; -import { useAccount, useChainId } from 'wagmi'; import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useAccount, useChainId } from 'wagmi'; import { Spinner } from '../../../../internal/components/Spinner'; import { cn, color, text } from '../../../../styles/theme'; import { diff --git a/src/ui/react/nft/mint/NFTMinters.test.tsx b/src/ui/react/nft/mint/NFTMinters.test.tsx index b3503741aa..61a7e5003d 100644 --- a/src/ui/react/nft/mint/NFTMinters.test.tsx +++ b/src/ui/react/nft/mint/NFTMinters.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTMinters } from './NFTMinters'; vi.mock('@/core-react/nft/providers/NFTProvider'); diff --git a/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx index 61820ccc81..366ecb8988 100644 --- a/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx +++ b/src/ui/react/nft/mint/NFTQuantitySelector.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { fireEvent, render } from '@testing-library/react'; import { act } from 'react'; import { @@ -10,7 +11,6 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTQuantitySelector } from './NFTQuantitySelector'; vi.mock('@/core-react/nft/providers/NFTProvider'); diff --git a/src/ui/react/nft/mint/NFTTotalCost.test.tsx b/src/ui/react/nft/mint/NFTTotalCost.test.tsx index c74ff6f9b6..6e4ca67dc4 100644 --- a/src/ui/react/nft/mint/NFTTotalCost.test.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { fireEvent, render } from '@testing-library/react'; import { type Mock, @@ -9,7 +10,6 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTTotalCost } from './NFTTotalCost'; vi.mock('@/core-react/nft/providers/NFTProvider'); diff --git a/src/ui/react/nft/mint/NFTTotalCost.tsx b/src/ui/react/nft/mint/NFTTotalCost.tsx index 2dcae017fd..90ea493617 100644 --- a/src/ui/react/nft/mint/NFTTotalCost.tsx +++ b/src/ui/react/nft/mint/NFTTotalCost.tsx @@ -1,6 +1,6 @@ -import { type ReactNode, useCallback, useMemo, useState } from 'react'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { multiplyFloats } from '@/core/utils/multiplyFloats'; +import { type ReactNode, useCallback, useMemo, useState } from 'react'; import { infoSvg } from '../../../../internal/svg/infoSvg'; import { background, border, cn, text } from '../../../../styles/theme'; import { formatAmount } from '../../../../token/utils/formatAmount'; diff --git a/src/ui/react/nft/view/NFTAudio.test.tsx b/src/ui/react/nft/view/NFTAudio.test.tsx index 0f976e35ee..860e601c65 100644 --- a/src/ui/react/nft/view/NFTAudio.test.tsx +++ b/src/ui/react/nft/view/NFTAudio.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { fireEvent, render } from '@testing-library/react'; import { type Mock, @@ -9,7 +10,6 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTAudio } from './NFTAudio'; const mockAnimationUrl = 'https://example.com/audio.mp3'; diff --git a/src/ui/react/nft/view/NFTAudio.tsx b/src/ui/react/nft/view/NFTAudio.tsx index df3e001e2b..aa22f53cd0 100644 --- a/src/ui/react/nft/view/NFTAudio.tsx +++ b/src/ui/react/nft/view/NFTAudio.tsx @@ -1,3 +1,5 @@ +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import type { NFTError } from '@/core-react/nft/types'; import { type MouseEvent, useCallback, @@ -5,8 +7,6 @@ import { useRef, useState, } from 'react'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; -import type { NFTError } from '@/core-react/nft/types'; import { background, cn } from '../../../../styles/theme'; type NFTAudioReact = { diff --git a/src/ui/react/nft/view/NFTImage.test.tsx b/src/ui/react/nft/view/NFTImage.test.tsx index 027341f794..47ec65c82a 100644 --- a/src/ui/react/nft/view/NFTImage.test.tsx +++ b/src/ui/react/nft/view/NFTImage.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { fireEvent, render, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTImage } from './NFTImage'; const mockContext = { diff --git a/src/ui/react/nft/view/NFTImage.tsx b/src/ui/react/nft/view/NFTImage.tsx index 4093e823a4..57caea1da1 100644 --- a/src/ui/react/nft/view/NFTImage.tsx +++ b/src/ui/react/nft/view/NFTImage.tsx @@ -1,6 +1,6 @@ -import { type MouseEvent, useCallback, useEffect, useState } from 'react'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import type { NFTError } from '@/core-react/nft/types'; +import { type MouseEvent, useCallback, useEffect, useState } from 'react'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx index 3fdf99b05c..872997f9de 100644 --- a/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, @@ -9,7 +10,6 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTLastSoldPrice } from './NFTLastSoldPrice'; vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ diff --git a/src/ui/react/nft/view/NFTLastSoldPrice.tsx b/src/ui/react/nft/view/NFTLastSoldPrice.tsx index 76701fac11..7175bea0f1 100644 --- a/src/ui/react/nft/view/NFTLastSoldPrice.tsx +++ b/src/ui/react/nft/view/NFTLastSoldPrice.tsx @@ -1,5 +1,5 @@ -import type { ReactNode } from 'react'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import type { ReactNode } from 'react'; import { cn, color, text } from '../../../../styles/theme'; import { formatAmount as formatSN } from '../../../../swap/utils/formatAmount'; import { formatAmount } from '../../../../token/utils/formatAmount'; diff --git a/src/ui/react/nft/view/NFTMedia.test.tsx b/src/ui/react/nft/view/NFTMedia.test.tsx index 56fbfd4ad6..21d70a8621 100644 --- a/src/ui/react/nft/view/NFTMedia.test.tsx +++ b/src/ui/react/nft/view/NFTMedia.test.tsx @@ -1,9 +1,9 @@ import '@testing-library/jest-dom'; -import { fireEvent, render } from '@testing-library/react'; -import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { LifecycleType } from '@/core-react/nft/types'; +import { fireEvent, render } from '@testing-library/react'; +import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; import { NFTMedia } from './NFTMedia'; vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ diff --git a/src/ui/react/nft/view/NFTMedia.tsx b/src/ui/react/nft/view/NFTMedia.tsx index 46426930bd..9aac949c5e 100644 --- a/src/ui/react/nft/view/NFTMedia.tsx +++ b/src/ui/react/nft/view/NFTMedia.tsx @@ -1,4 +1,3 @@ -import { useCallback, useMemo } from 'react'; import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { @@ -6,6 +5,7 @@ import { MediaType, type NFTError, } from '@/core-react/nft/types'; +import { useCallback, useMemo } from 'react'; import { cn } from '../../../../styles/theme'; import { NFTAudio } from './NFTAudio'; import { NFTImage } from './NFTImage'; diff --git a/src/ui/react/nft/view/NFTMintDate.test.tsx b/src/ui/react/nft/view/NFTMintDate.test.tsx index 328e3f1e9f..73b84347e3 100644 --- a/src/ui/react/nft/view/NFTMintDate.test.tsx +++ b/src/ui/react/nft/view/NFTMintDate.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTMintDate } from './NFTMintDate'; vi.mock('@/core-react/nft/providers/NFTProvider'); diff --git a/src/ui/react/nft/view/NFTMintDate.tsx b/src/ui/react/nft/view/NFTMintDate.tsx index a43be0a6d6..aa23c0e7fa 100644 --- a/src/ui/react/nft/view/NFTMintDate.tsx +++ b/src/ui/react/nft/view/NFTMintDate.tsx @@ -1,5 +1,5 @@ -import { type ReactNode, useMemo } from 'react'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { type ReactNode, useMemo } from 'react'; import { cn, color, text } from '../../../../styles/theme'; const DATE_OPTIONS = { diff --git a/src/ui/react/nft/view/NFTOwner.test.tsx b/src/ui/react/nft/view/NFTOwner.test.tsx index 8ecc1d166f..db46572c54 100644 --- a/src/ui/react/nft/view/NFTOwner.test.tsx +++ b/src/ui/react/nft/view/NFTOwner.test.tsx @@ -1,4 +1,6 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; +import { useOnchainKit } from '@/core-react/useOnchainKit'; import { render } from '@testing-library/react'; import { type Mock, @@ -9,8 +11,6 @@ import { it, vi, } from 'vitest'; -import { useOnchainKit } from '@/core-react/useOnchainKit'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTOwner } from './NFTOwner'; vi.mock('@/core-react/useOnchainKit'); diff --git a/src/ui/react/nft/view/NFTOwner.tsx b/src/ui/react/nft/view/NFTOwner.tsx index 4cee201a7b..621ec1a812 100644 --- a/src/ui/react/nft/view/NFTOwner.tsx +++ b/src/ui/react/nft/view/NFTOwner.tsx @@ -1,6 +1,6 @@ -import type { ReactNode } from 'react'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { useOnchainKit } from '@/core-react/useOnchainKit'; +import type { ReactNode } from 'react'; import { Avatar, Badge, Identity, Name } from '../../../../identity'; import { cn, color, text } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/view/NFTTitle.test.tsx b/src/ui/react/nft/view/NFTTitle.test.tsx index 6ac1228112..d8b7e1c4e2 100644 --- a/src/ui/react/nft/view/NFTTitle.test.tsx +++ b/src/ui/react/nft/view/NFTTitle.test.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { render } from '@testing-library/react'; import { type Mock, describe, expect, it, vi } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTTitle } from './NFTTitle'; vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ diff --git a/src/ui/react/nft/view/NFTVideo.test.tsx b/src/ui/react/nft/view/NFTVideo.test.tsx index 7b2df2611f..7a359a1fb3 100644 --- a/src/ui/react/nft/view/NFTVideo.test.tsx +++ b/src/ui/react/nft/view/NFTVideo.test.tsx @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { fireEvent, render } from '@testing-library/react'; import { type Mock, @@ -9,7 +10,6 @@ import { it, vi, } from 'vitest'; -import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import { NFTVideo } from './NFTVideo'; vi.mock('@/core-react/nft/providers/NFTProvider', () => ({ diff --git a/src/ui/react/nft/view/NFTVideo.tsx b/src/ui/react/nft/view/NFTVideo.tsx index 3ea75869c7..7ef59d6966 100644 --- a/src/ui/react/nft/view/NFTVideo.tsx +++ b/src/ui/react/nft/view/NFTVideo.tsx @@ -1,6 +1,6 @@ -import { useEffect, useRef } from 'react'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; import type { NFTError } from '@/core-react/nft/types'; +import { useEffect, useRef } from 'react'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; From 70f838db3b7b31d107364a322e4ca08b8186129a Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Fri, 13 Dec 2024 12:33:15 -0500 Subject: [PATCH 8/9] fix: more types --- src/core-react/nft/hooks/useMintData.ts | 2 +- .../nft/hooks/useMintDetails.test.ts | 4 ++-- src/core-react/nft/hooks/useMintDetails.ts | 9 +++----- src/core-react/nft/hooks/useNFTData.ts | 2 +- .../nft/hooks/useTokenDetails.test.ts | 4 ++-- src/core-react/nft/hooks/useTokenDetails.ts | 9 +++----- src/core-react/nft/types.ts | 23 ++----------------- src/core/api/types.ts | 20 +++++++++++++++- src/core/nft/utils/isNFTError.ts | 2 +- src/transaction/index.ts | 2 +- src/transaction/types.ts | 10 +------- src/ui/react/nft/index.ts | 2 +- src/ui/react/nft/view/NFTMedia.tsx | 7 ++---- 13 files changed, 39 insertions(+), 57 deletions(-) diff --git a/src/core-react/nft/hooks/useMintData.ts b/src/core-react/nft/hooks/useMintData.ts index 1f23870498..e7f1e9a125 100644 --- a/src/core-react/nft/hooks/useMintData.ts +++ b/src/core-react/nft/hooks/useMintData.ts @@ -1,6 +1,6 @@ +import { convertIpfsToHttps } from '@/core/nft/utils/ipfs'; import { useEffect, useState } from 'react'; import { useAccount } from 'wagmi'; -import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import type { NFTData, NFTError } from '../types'; import { useMintDetails } from './useMintDetails'; diff --git a/src/core-react/nft/hooks/useMintDetails.test.ts b/src/core-react/nft/hooks/useMintDetails.test.ts index 3b8094d119..6df34015dc 100644 --- a/src/core-react/nft/hooks/useMintDetails.test.ts +++ b/src/core-react/nft/hooks/useMintDetails.test.ts @@ -1,10 +1,10 @@ +import { getMintDetails } from '@/core/api/getMintDetails'; import { renderHook, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { getMintDetails } from '../../../core/api/getMintDetails'; import { getNewReactQueryTestProvider } from '../../../identity/hooks/getNewReactQueryTestProvider'; import { useMintDetails } from './useMintDetails'; -vi.mock('../../../core/api/getMintDetails'); +vi.mock('@/core/api/getMintDetails'); describe('useMintDetails', () => { beforeEach(() => { diff --git a/src/core-react/nft/hooks/useMintDetails.ts b/src/core-react/nft/hooks/useMintDetails.ts index 24f53d0576..d7a33ca1ff 100644 --- a/src/core-react/nft/hooks/useMintDetails.ts +++ b/src/core-react/nft/hooks/useMintDetails.ts @@ -1,10 +1,7 @@ +import { getMintDetails } from '@/core/api/getMintDetails'; +import type { GetMintDetailsParams, MintDetails } from '@/core/api/types'; +import { isNFTError } from '@/core/nft/utils/isNFTError'; import { type UseQueryResult, useQuery } from '@tanstack/react-query'; -import { getMintDetails } from '../../../core/api/getMintDetails'; -import type { - GetMintDetailsParams, - MintDetails, -} from '../../../core/api/types'; -import { isNFTError } from '../../../core/nft/utils/isNFTError'; export function useMintDetails({ contractAddress, diff --git a/src/core-react/nft/hooks/useNFTData.ts b/src/core-react/nft/hooks/useNFTData.ts index b4f3127b9f..8fffd3fe2d 100644 --- a/src/core-react/nft/hooks/useNFTData.ts +++ b/src/core-react/nft/hooks/useNFTData.ts @@ -1,5 +1,5 @@ +import { convertIpfsToHttps } from '@/core/nft/utils/ipfs'; import { useEffect, useState } from 'react'; -import { convertIpfsToHttps } from '../../../core/nft/utils/ipfs'; import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; import type { ContractType, NFTData, NFTError } from '../types'; import { useTokenDetails } from './useTokenDetails'; diff --git a/src/core-react/nft/hooks/useTokenDetails.test.ts b/src/core-react/nft/hooks/useTokenDetails.test.ts index a03d5b831a..b9e2905d1b 100644 --- a/src/core-react/nft/hooks/useTokenDetails.test.ts +++ b/src/core-react/nft/hooks/useTokenDetails.test.ts @@ -1,10 +1,10 @@ +import { getTokenDetails } from '@/core/api/getTokenDetails'; import { renderHook, waitFor } from '@testing-library/react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; -import { getTokenDetails } from '../../../core/api/getTokenDetails'; import { getNewReactQueryTestProvider } from '../../../identity/hooks/getNewReactQueryTestProvider'; import { useTokenDetails } from './useTokenDetails'; -vi.mock('../../../core/api/getTokenDetails'); +vi.mock('@/core/api/getTokenDetails'); describe('useTokenDetails', () => { beforeEach(() => { diff --git a/src/core-react/nft/hooks/useTokenDetails.ts b/src/core-react/nft/hooks/useTokenDetails.ts index b4194e8ab6..433ff81a2c 100644 --- a/src/core-react/nft/hooks/useTokenDetails.ts +++ b/src/core-react/nft/hooks/useTokenDetails.ts @@ -1,10 +1,7 @@ +import { getTokenDetails } from '@/core/api/getTokenDetails'; +import type { GetTokenDetailsParams, TokenDetails } from '@/core/api/types'; +import { isNFTError } from '@/core/nft/utils/isNFTError'; import { type UseQueryResult, useQuery } from '@tanstack/react-query'; -import { getTokenDetails } from '../../../core/api/getTokenDetails'; -import type { - GetTokenDetailsParams, - TokenDetails, -} from '../../../core/api/types'; -import { isNFTError } from '../../../core/nft/utils/isNFTError'; export function useTokenDetails({ contractAddress, diff --git a/src/core-react/nft/types.ts b/src/core-react/nft/types.ts index f6c8edbbc5..5b94dcf6a8 100644 --- a/src/core-react/nft/types.ts +++ b/src/core-react/nft/types.ts @@ -1,8 +1,7 @@ +import type { ContractType, NFTError, NFTPrice } from '@/core/api/types'; import type { ReactNode } from 'react'; import type { Address, Hex, TransactionReceipt } from 'viem'; -import type { Call, TransactionError } from '../../transaction/types'; - -export type ContractType = 'ERC721' | 'ERC1155'; +import type { Call } from '../../transaction/types'; export enum MediaType { Image = 'image', @@ -52,12 +51,6 @@ export type NFTProviderReact = { buildMintTransaction?: BuildMintTransaction; }; -export type NFTPrice = { - amount?: string; // Amount in Currency - currency?: string; // Currency - amountUSD?: string; // Amount in USD -}; - /** * Note: exported as public Type */ @@ -160,18 +153,6 @@ export type NFTMintCardReact = { */ export type NFTMintCardDefaultReact = Omit; -/** -/** - * Note: exported as public Type - */ -export type NFTError = - | { - code: string; // The error code representing the type of nft error. - error: string; // The error message providing details about the nft error. - message: string; // The error message providing details about the nft error. - } - | TransactionError; - export type LifecycleStatus = | { statusName: 'init'; diff --git a/src/core/api/types.ts b/src/core/api/types.ts index 7facf00239..281fc3bc7b 100644 --- a/src/core/api/types.ts +++ b/src/core/api/types.ts @@ -1,5 +1,4 @@ import type { Address } from 'viem'; -import type { ContractType, NFTPrice } from '../../core-react/nft/types'; import type { Fee, QuoteWarning, @@ -19,6 +18,17 @@ export type APIError = { message: string; // The Error short message }; +/** + * Note: exported as public Type + */ +export type TransactionError = APIError; + +/** +/** + * Note: exported as public Type + */ +export type NFTError = APIError | TransactionError; + /** * Note: exported as public Type */ @@ -150,6 +160,14 @@ export type RawTransactionData = { export type SwapAPIParams = GetQuoteAPIParams | GetSwapAPIParams; +export type ContractType = 'ERC721' | 'ERC1155'; + +export type NFTPrice = { + amount?: string; // Amount in Currency + currency?: string; // Currency + amountUSD?: string; // Amount in USD +}; + /** * Note: exported as public Type */ diff --git a/src/core/nft/utils/isNFTError.ts b/src/core/nft/utils/isNFTError.ts index 5e6937aafa..3291fc18ce 100644 --- a/src/core/nft/utils/isNFTError.ts +++ b/src/core/nft/utils/isNFTError.ts @@ -1,4 +1,4 @@ -import type { NFTError } from '../../../core-react/nft/types'; +import type { NFTError } from '@/core/api/types'; export function isNFTError(response: unknown): response is NFTError { return ( diff --git a/src/transaction/index.ts b/src/transaction/index.ts index b337f30764..0040aa62f1 100644 --- a/src/transaction/index.ts +++ b/src/transaction/index.ts @@ -13,7 +13,6 @@ export { TransactionToastLabel } from './components/TransactionToastLabel'; export type { LifecycleStatus, TransactionButtonReact, - TransactionError, TransactionReact, TransactionResponse, TransactionSponsorReact, @@ -26,3 +25,4 @@ export type { TransactionToastLabelReact, WalletCapabilities, } from './types'; +export type { TransactionError } from '@/core/api/types'; diff --git a/src/transaction/types.ts b/src/transaction/types.ts index 2539a01846..460700a733 100644 --- a/src/transaction/types.ts +++ b/src/transaction/types.ts @@ -1,4 +1,5 @@ // 🌲☀🌲 +import type { TransactionError } from '@/core/api/types'; import type { ReactNode } from 'react'; import type { Address, @@ -120,15 +121,6 @@ export type TransactionDefaultReact = { disabled?: boolean; } & Omit; -/** - * Note: exported as public Type - */ -export type TransactionError = { - code: string; // The error code representing the type of transaction error. - error: string; // The error message providing details about the transaction error. - message: string; // The error message providing details about the transaction error. -}; - export type Calls = Call[] | Promise | (() => Promise); export type Contracts = | ContractFunctionParameters[] diff --git a/src/ui/react/nft/index.ts b/src/ui/react/nft/index.ts index bab84bc955..25876d7cbf 100644 --- a/src/ui/react/nft/index.ts +++ b/src/ui/react/nft/index.ts @@ -9,8 +9,8 @@ export type { NFTCardReact, NFTCardDefaultReact, NFTData, - NFTError, NFTMintCardReact, NFTMintCardDefaultReact, UseNFTData, } from '@/core-react/nft/types'; +export type { NFTError } from '@/core/api/types'; diff --git a/src/ui/react/nft/view/NFTMedia.tsx b/src/ui/react/nft/view/NFTMedia.tsx index 9aac949c5e..e289f0257a 100644 --- a/src/ui/react/nft/view/NFTMedia.tsx +++ b/src/ui/react/nft/view/NFTMedia.tsx @@ -1,10 +1,7 @@ import { useNFTLifecycleContext } from '@/core-react/nft/providers/NFTLifecycleProvider'; import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; -import { - LifecycleType, - MediaType, - type NFTError, -} from '@/core-react/nft/types'; +import { LifecycleType, MediaType } from '@/core-react/nft/types'; +import type { NFTError } from '@/core/api/types'; import { useCallback, useMemo } from 'react'; import { cn } from '../../../../styles/theme'; import { NFTAudio } from './NFTAudio'; From fd57b8306e16e7559722df894c2567af95b8e0f0 Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Fri, 13 Dec 2024 12:59:54 -0500 Subject: [PATCH 9/9] fixes --- src/core-react/nft/hooks/useMintData.ts | 3 ++- src/core-react/nft/hooks/useNFTData.ts | 3 ++- .../nft/providers/NFTLifecycleProvider.test.tsx | 8 ++------ src/ui/react/nft/view/NFTAudio.tsx | 2 +- src/ui/react/nft/view/NFTImage.tsx | 2 +- src/ui/react/nft/view/NFTVideo.tsx | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/core-react/nft/hooks/useMintData.ts b/src/core-react/nft/hooks/useMintData.ts index e7f1e9a125..444faad37c 100644 --- a/src/core-react/nft/hooks/useMintData.ts +++ b/src/core-react/nft/hooks/useMintData.ts @@ -1,8 +1,9 @@ +import type { NFTError } from '@/core/api/types'; import { convertIpfsToHttps } from '@/core/nft/utils/ipfs'; import { useEffect, useState } from 'react'; import { useAccount } from 'wagmi'; import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; -import type { NFTData, NFTError } from '../types'; +import type { NFTData } from '../types'; import { useMintDetails } from './useMintDetails'; export function useMintData( diff --git a/src/core-react/nft/hooks/useNFTData.ts b/src/core-react/nft/hooks/useNFTData.ts index 8fffd3fe2d..4e52a51456 100644 --- a/src/core-react/nft/hooks/useNFTData.ts +++ b/src/core-react/nft/hooks/useNFTData.ts @@ -1,7 +1,8 @@ +import type { ContractType, NFTError } from '@/core/api/types'; import { convertIpfsToHttps } from '@/core/nft/utils/ipfs'; import { useEffect, useState } from 'react'; import { useNFTLifecycleContext } from '../providers/NFTLifecycleProvider'; -import type { ContractType, NFTData, NFTError } from '../types'; +import type { NFTData } from '../types'; import { useTokenDetails } from './useTokenDetails'; export function useNFTData( diff --git a/src/core-react/nft/providers/NFTLifecycleProvider.test.tsx b/src/core-react/nft/providers/NFTLifecycleProvider.test.tsx index cf386e9ada..4df0b2a911 100644 --- a/src/core-react/nft/providers/NFTLifecycleProvider.test.tsx +++ b/src/core-react/nft/providers/NFTLifecycleProvider.test.tsx @@ -1,13 +1,9 @@ import '@testing-library/jest-dom'; +import type { NFTError } from '@/core/api/types'; import { fireEvent, render } from '@testing-library/react'; import type { TransactionReceipt } from 'viem'; import { describe, expect, it, vi } from 'vitest'; -import { - type LifecycleStatus, - LifecycleType, - MediaType, - type NFTError, -} from '../types'; +import { type LifecycleStatus, LifecycleType, MediaType } from '../types'; import { NFTLifecycleProvider, useNFTLifecycleContext, diff --git a/src/ui/react/nft/view/NFTAudio.tsx b/src/ui/react/nft/view/NFTAudio.tsx index aa22f53cd0..2f583492ae 100644 --- a/src/ui/react/nft/view/NFTAudio.tsx +++ b/src/ui/react/nft/view/NFTAudio.tsx @@ -1,5 +1,5 @@ import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; -import type { NFTError } from '@/core-react/nft/types'; +import type { NFTError } from '@/core/api/types'; import { type MouseEvent, useCallback, diff --git a/src/ui/react/nft/view/NFTImage.tsx b/src/ui/react/nft/view/NFTImage.tsx index 57caea1da1..7fc7757b9f 100644 --- a/src/ui/react/nft/view/NFTImage.tsx +++ b/src/ui/react/nft/view/NFTImage.tsx @@ -1,5 +1,5 @@ import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; -import type { NFTError } from '@/core-react/nft/types'; +import type { NFTError } from '@/core/api/types'; import { type MouseEvent, useCallback, useEffect, useState } from 'react'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme'; diff --git a/src/ui/react/nft/view/NFTVideo.tsx b/src/ui/react/nft/view/NFTVideo.tsx index 7ef59d6966..0cab84e9ad 100644 --- a/src/ui/react/nft/view/NFTVideo.tsx +++ b/src/ui/react/nft/view/NFTVideo.tsx @@ -1,5 +1,5 @@ import { useNFTContext } from '@/core-react/nft/providers/NFTProvider'; -import type { NFTError } from '@/core-react/nft/types'; +import type { NFTError } from '@/core/api/types'; import { useEffect, useRef } from 'react'; import { defaultNFTSvg } from '../../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../../styles/theme';