From 85409aff9b0f4d638482cd7a9ed935b836fa9280 Mon Sep 17 00:00:00 2001 From: Corantin Date: Fri, 7 Jun 2024 10:54:50 -0400 Subject: [PATCH] Fix metadata --- .../nextjs/components/PropertyListBuy.tsx | 11 ++++- .../nextjs/contracts/deployedContracts.ts | 45 +++++++------------ .../contracts/deed-nft/useDeedMint.hook.ts | 9 +++- packages/nextjs/models/deed-info.model.ts | 9 +++- packages/nextjs/pages/_app.tsx | 2 +- 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/packages/nextjs/components/PropertyListBuy.tsx b/packages/nextjs/components/PropertyListBuy.tsx index 6b7cb9d2..1d0cbb17 100644 --- a/packages/nextjs/components/PropertyListBuy.tsx +++ b/packages/nextjs/components/PropertyListBuy.tsx @@ -1,3 +1,5 @@ +"use client"; + import { useState } from "react"; import { BidModal, @@ -32,10 +34,11 @@ const BidOffers = ({ deedData }: Props) => { const listOpenState = useState(false); const { connectWallet } = useWallet(); const { fees } = useFeesClient(); - + const { id: chainId } = getTargetNetwork(); const listings = useListings({ token: tokenWithId, }); + const bids = useBids({ normalizeRoyalties: true, token: tokenWithId, @@ -73,7 +76,11 @@ const BidOffers = ({ deedData }: Props) => { notification.success("Property listed"); }} onGoToToken={() => { - notification.info("Comming soon..."); + window.open( + chainId === 137 + ? `https://opensea.io/assets/matic/${deedNFTAddresss}/${deedData.mintedId}` + : `https://testnets.opensea.io/assets/sepolia/${deedNFTAddresss}/${deedData.mintedId}`, + ); }} onClose={() => { listings.mutate(); diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index d2f94ec4..91f281ed 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -369,16 +369,11 @@ const deployedContracts = { inheritedFunctions: { DEFAULT_ADMIN_ROLE: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - getRoleAdmin: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - grantRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - hasRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - renounceRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - revokeRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + getRoleAdmin: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + grantRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + hasRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + renounceRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + revokeRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", supportsInterface: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", }, @@ -1974,16 +1969,11 @@ const deployedContracts = { inheritedFunctions: { DEFAULT_ADMIN_ROLE: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - getRoleAdmin: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - grantRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - hasRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - renounceRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - revokeRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + getRoleAdmin: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + grantRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + hasRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + renounceRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + revokeRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", supportsInterface: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", }, @@ -3582,16 +3572,11 @@ const deployedContracts = { inheritedFunctions: { DEFAULT_ADMIN_ROLE: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - getRoleAdmin: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - grantRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - hasRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - renounceRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", - revokeRole: - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + getRoleAdmin: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + grantRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + hasRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + renounceRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", + revokeRole: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", supportsInterface: "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol", }, diff --git a/packages/nextjs/hooks/contracts/deed-nft/useDeedMint.hook.ts b/packages/nextjs/hooks/contracts/deed-nft/useDeedMint.hook.ts index a7710c0a..f731667c 100644 --- a/packages/nextjs/hooks/contracts/deed-nft/useDeedMint.hook.ts +++ b/packages/nextjs/hooks/contracts/deed-nft/useDeedMint.hook.ts @@ -4,7 +4,7 @@ import useDeedClient from "~~/clients/deeds.client"; import useFileClient from "~~/clients/files.client"; import { PropertyTypeOptions } from "~~/constants"; import useWallet from "~~/hooks/useWallet"; -import { DeedInfoModel } from "~~/models/deed-info.model"; +import { DeedInfoModel, OpenSeaMetadata } from "~~/models/deed-info.model"; import { uploadFiles } from "~~/services/file.service"; import logger from "~~/services/logger.service"; import { indexOfLiteral } from "~~/utils/extract-values"; @@ -30,10 +30,15 @@ const useDeedMint = (onConfirmed?: (txnReceipt: TransactionReceipt) => void) => const toastId = notification.loading("Publishing documents..."); let hash; - let payload: DeedInfoModel; + let payload: DeedInfoModel & OpenSeaMetadata; try { payload = await uploadFiles(authToken, data, undefined, true); if (!payload) return; + // Fill NFT metadata as OpenSea standard + payload.name = data.propertyDetails.propertyAddress; + payload.description = data.propertyDetails.propertyDescription; + payload.image = payload.propertyDetails.propertyImages?.[0].fileId; + payload.external_url = `https://app.deed3.io/overview/${payload.id}`; hash = await fileClient.uploadJson(payload); } catch (error) { notification.error("Error while publishing documents"); diff --git a/packages/nextjs/models/deed-info.model.ts b/packages/nextjs/models/deed-info.model.ts index ee7558aa..35f14079 100644 --- a/packages/nextjs/models/deed-info.model.ts +++ b/packages/nextjs/models/deed-info.model.ts @@ -1,4 +1,5 @@ import { FileModel } from "./file.model"; +import { TokenModel } from "./token.model"; import { Address } from "viem"; import { EntityTypeOptions, @@ -12,7 +13,6 @@ import { WrapperOptions, } from "~~/constants"; import { ValueExtractor } from "~~/utils/extract-values"; -import { TokenModel } from "./token.model"; export interface OwnerInformationModel { ownerType: ValueExtractor; @@ -115,3 +115,10 @@ export interface DeedInfoModel { signatureTx?: string; } + +export interface OpenSeaMetadata { + name?: string; + description?: string; + image?: string; + external_url?: string; +} diff --git a/packages/nextjs/pages/_app.tsx b/packages/nextjs/pages/_app.tsx index 21378fb6..01faf1ec 100644 --- a/packages/nextjs/pages/_app.tsx +++ b/packages/nextjs/pages/_app.tsx @@ -48,7 +48,7 @@ const ScaffoldEthApp = (props: AppProps) => { chains: [ { ...reservoirChains[ - (process.env.NEXT_PUBLIC_TARGET_NETWORK ?? "polygon") as keyof typeof reservoirChains + (process.env.NEXT_PUBLIC_TARGET_NETWORK ?? "sepolia") as keyof typeof reservoirChains ], active: true, },