Skip to content

Commit fe2cb0c

Browse files
authored
Merge pull request #436 from yieldprotocol/feat/removeCenterDependance
remove center api dependance
2 parents 7467295 + 1830a1b commit fe2cb0c

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

.env.example

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ NEXT_PUBLIC_TENDERLY_FORK_ID=
66
NEXT_PUBLIC_TENDERLY_USER=
77
NEXT_PUBLIC_TENDERLY_PROJECT=
88
NEXT_PUBLIC_TENDERLY_ACCESS_KEY=
9-
NEXT_PUBLIC_CENTER_APP_KEY=
10-
NEXT_PUBLIC_OPENSEA_API_KEY=
9+
1110
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
1211

1312
NEXTAUTH_URL=http://localhost:3000

src/components/current/widgets/nft/NftAsset.tsx

+21-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Address } from 'wagmi';
33
import { ImageResponse } from '@/components/cactiComponents';
44
import { ImageVariant } from '@/components/cactiComponents/ImageResponse';
55
import { InlineChip } from '@/components/cactiComponents/InlineChip';
6-
import useNft from '@/hooks/useNft';
76

87
export interface NftAssetProps {
98
network: Network;
@@ -14,6 +13,20 @@ export interface NftAssetProps {
1413
previewImageUrl?: string;
1514
variant?: ImageVariant; // widget variant
1615
price?: string;
16+
attributes?: {trait_type: string, value: string}[];
17+
}
18+
19+
const TraitList = ({ attributes }: { attributes: {trait_type: string, value: string}[] }) => {
20+
return (
21+
<div className="">
22+
{attributes.map((attribute, index) => (
23+
<div key={index} className="text-xs mr-2 mb-2">
24+
<span className="font-bold">{attribute.trait_type}</span>: {attribute.value}
25+
</div>
26+
))}
27+
</div>
28+
)
29+
1730
}
1831

1932
export const NftAsset = ({
@@ -25,25 +38,26 @@ export const NftAsset = ({
2538
previewImageUrl,
2639
variant,
2740
price,
41+
attributes
2842
}: NftAssetProps) => {
29-
const { data: nftData } = useNft({ network, address, tokenId });
3043

3144
return (
3245
<ImageResponse
33-
image={nftData.smallPreviewImageUrl || previewImageUrl}
46+
image={previewImageUrl}
3447
imageTags={
3548
variant === ImageVariant.SHOWCASE
3649
? [`Token Id: ${tokenId}`, `${network.replace('-mainnet', '')}`]
3750
: [`Token Id: ${tokenId}`] // always show the token id
3851
}
39-
title={nftData.name || name}
40-
subTitle={nftData.collectionName || collectionName}
52+
title={name}
53+
subTitle={collectionName}
4154
imageLink={`https://center.app/${network}/collections/${address}/${tokenId}`}
4255
variant={variant}
4356
>
44-
{variant === ImageVariant.SHOWCASE && (
57+
{/* {variant === ImageVariant.SHOWCASE && (
4558
<div className="text-xs">{nftData.metadata?.description}</div>
46-
)}
59+
)} */}
60+
{attributes && <TraitList attributes={attributes} />}
4761
{price && (
4862
<InlineChip
4963
className="text-xs"

src/components/current/widgets/nft/NftCollection.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ImageVariant } from '@/components/cactiComponents/ImageResponse';
55
import { Widget } from '../../MessageTranslator';
66
import ListContainer from '../../containers/ListContainer';
77
import { NftAsset } from './NftAsset';
8+
import { abbreviateHash } from '@/utils';
89

910
interface NftCollectionContainerProps {
1011
network: Network;
@@ -27,11 +28,7 @@ export const NftCollection = ({
2728
variant,
2829
assetsToShow = [],
2930
}: NftCollectionContainerProps) => {
30-
const collection = useCollection({
31-
network,
32-
address,
33-
});
34-
31+
3532
/**
3633
* Get the array of the asset ids to show:
3734
* */
@@ -55,10 +52,10 @@ export const NftCollection = ({
5552
<ListContainer
5653
items={[
5754
<ImageResponse
58-
image={collection?.smallPreviewImageUrl || previewImageUrl}
59-
imageTags={[`${(numAssets || collection?.numAssets || 'Unknown')!.toString()} Assets`]}
60-
title={collection?.name || name}
61-
subTitle={collection?.symbol || collection?.name}
55+
image={previewImageUrl}
56+
imageTags={[`${(numAssets || 'Unknown')!.toString()} Assets`, network.split("-")[0] ]}
57+
title={name}
58+
subTitle={abbreviateHash(address,8)}
6259
imageLink={`https://center.app/${network}/collections/${address}`}
6360
key={address}
6461
variant={variant}
File renamed without changes.

0 commit comments

Comments
 (0)