Skip to content

Commit

Permalink
Fix metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Corantin committed Jun 7, 2024
1 parent 939a15a commit 85409af
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 36 deletions.
11 changes: 9 additions & 2 deletions packages/nextjs/components/PropertyListBuy.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useState } from "react";
import {
BidModal,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
45 changes: 15 additions & 30 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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",
},
Expand Down Expand Up @@ -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",
},
Expand Down
9 changes: 7 additions & 2 deletions packages/nextjs/hooks/contracts/deed-nft/useDeedMint.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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");
Expand Down
9 changes: 8 additions & 1 deletion packages/nextjs/models/deed-info.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FileModel } from "./file.model";
import { TokenModel } from "./token.model";
import { Address } from "viem";
import {
EntityTypeOptions,
Expand All @@ -12,7 +13,6 @@ import {
WrapperOptions,
} from "~~/constants";
import { ValueExtractor } from "~~/utils/extract-values";
import { TokenModel } from "./token.model";

export interface OwnerInformationModel {
ownerType: ValueExtractor<typeof OwnerTypeOptions>;
Expand Down Expand Up @@ -115,3 +115,10 @@ export interface DeedInfoModel {

signatureTx?: string;
}

export interface OpenSeaMetadata {
name?: string;
description?: string;
image?: string;
external_url?: string;
}
2 changes: 1 addition & 1 deletion packages/nextjs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 85409af

Please sign in to comment.