From 3ccbe66b63d0bcb6ac1c773daf4c35183f41cec7 Mon Sep 17 00:00:00 2001 From: umaresso Date: Sun, 6 Nov 2022 09:11:08 +0500 Subject: [PATCH 1/3] trying test nft --- contracts/WebsiteRent.sol | 6 +- pages/CreateDapp.jsx | 380 +++++++++++---------- pages/CreateSale.jsx | 2 +- pages/ExploreDapps.jsx | 8 +- pages/NftUpload.jsx | 56 ++- pages/components/DappInformationPopup.jsx | 4 +- pages/components/DeploymentCard.jsx | 14 +- pages/components/DropDownMenu.jsx | 15 +- pages/components/IntegrateFrontend.jsx | 253 ++++++++------ pages/components/LinkButton/LinkButton.jsx | 6 +- pages/data/NftRenting.js | 2 +- pages/data/Sale.js | 26 +- pages/data/WebsiteRent.js | 8 +- pages/data/Whitelist.js | 109 +++--- pages/data/ipfsStuff.js | 10 +- 15 files changed, 514 insertions(+), 385 deletions(-) diff --git a/contracts/WebsiteRent.sol b/contracts/WebsiteRent.sol index 2c7fc9a2f2a6..3fd612cbf88b 100644 --- a/contracts/WebsiteRent.sol +++ b/contracts/WebsiteRent.sol @@ -31,7 +31,7 @@ contract WebsiteRent { modifier ifWebsiteExists(string memory website) { require( websiteExists[website], - "The Website does not exist on HostMyNFT" + "The Website does not exist on RentWeb3" ); _; } @@ -45,8 +45,8 @@ contract WebsiteRent { rentTime[website] < block.timestamp, "Website is already rented" ); - require(msg.value >= prices[website]); - rentTime[website] = block.timestamp + (86400 * rentDays); + require(msg.value >= prices[website],"Insufficient Funds Sent"); + rentTime[website] = block.timestamp + (60 * rentDays); //replace 60 with 86400 websiteToDeployment[website] = deployment; deploymentToWebsite[deployment] = website; uint256 fee = (prices[website] * 5) / 100; diff --git a/pages/CreateDapp.jsx b/pages/CreateDapp.jsx index 413228765584..da24cb7a4dd6 100644 --- a/pages/CreateDapp.jsx +++ b/pages/CreateDapp.jsx @@ -12,52 +12,52 @@ import { Heading, Text, Link, -} from '@chakra-ui/react' -import React, { useEffect, useRef, useState } from 'react' -import NamedInput from './components/NamedInput' -import LinkButton from './components/LinkButton/LinkButton' -import { Web3Storage } from 'web3.storage' -import { getCustomNetworkWebsiteRentContract } from './data/WebsiteRent' -import { getAllDappsUris } from './data/ipfsStuff' -import { parseEther } from 'ethers/lib/utils' -import { useRouter } from 'next/router' -import { getProviderOrSigner } from './data/accountsConnection' +} from "@chakra-ui/react"; +import React, { useEffect, useRef, useState } from "react"; +import NamedInput from "./components/NamedInput"; +import LinkButton from "./components/LinkButton/LinkButton"; +import { Web3Storage } from "web3.storage"; +import { getCustomNetworkWebsiteRentContract } from "./data/WebsiteRent"; +import { getAllDappsUris } from "./data/ipfsStuff"; +import { parseEther } from "ethers/lib/utils"; +import { useRouter } from "next/router"; +import { getProviderOrSigner } from "./data/accountsConnection"; export async function getStaticProps(context) { - require('dotenv').config() + require("dotenv").config(); return { props: { token: process.env.WEB3STORAGE_TOKEN }, // will be passed to the page component as props - } + }; } -let NetworkChain = 'goerli' +let NetworkChain = "goerli"; function CreateDapp(props) { - const [name, setName] = useState('') - const [url, setUrl] = useState('https://') - const [price, setPrice] = useState('') - const [owner, setOwner] = useState('') - const [blockchain, setBlockchain] = useState('ethereum') - const [dappImage, setDappImage] = useState(null) - const [allDapps, setAllDapps] = useState([]) - const [loader, setLoader] = useState(false) - const [formStep, setFormStep] = useState(1) - const [type, setType] = useState('sale') - const router = useRouter() - const Web3ModalRef = useRef() - const [websiteRentContract, setWebsiteRentContract] = useState(null) + const [name, setName] = useState(""); + const [url, setUrl] = useState("https://"); + const [price, setPrice] = useState(""); + const [owner, setOwner] = useState(""); + const [blockchain, setBlockchain] = useState("ethereum"); + const [dappImage, setDappImage] = useState(null); + const [allDapps, setAllDapps] = useState([]); + const [loader, setLoader] = useState(false); + const [formStep, setFormStep] = useState(1); + const [type, setType] = useState("sale"); + const router = useRouter(); + const Web3ModalRef = useRef(); + const [websiteRentContract, setWebsiteRentContract] = useState(null); function getAccessToken() { - return props.token + return props.token; } function makeStorageClient() { - return new Web3Storage({ token: getAccessToken() }) + return new Web3Storage({ token: getAccessToken() }); } function getDappImage() { - const fileInput = document.querySelector('input[type="file"]') - return fileInput.files + const fileInput = document.querySelector('input[type="file"]'); + return fileInput.files; } async function makeDappFile() { - let imageCid = await storeDappImage() + let imageCid = await storeDappImage(); const obj = { name, @@ -68,19 +68,19 @@ function CreateDapp(props) { image: imageCid, type, id: allDapps.length + 1, - } - const blob = new Blob([JSON.stringify(obj)], { type: 'application/json' }) + }; + const blob = new Blob([JSON.stringify(obj)], { type: "application/json" }); - const files = [new File([blob], `metadata.json`)] + const files = [new File([blob], `metadata.json`)]; - return files + return files; } async function storeDappImage() { - const client = makeStorageClient() - const _file = new File(getDappImage(), 'img.PNG') - const cid = await client.put([_file]) - console.log('stored image on :', cid) - return cid + const client = makeStorageClient(); + const _file = new File(getDappImage(), "img.PNG"); + const cid = await client.put([_file]); + console.log("stored image on :", cid); + return cid; } async function StoreUpdatedDappsOnIpfs(dappArray) { const _blob = new Blob( @@ -89,166 +89,174 @@ function CreateDapp(props) { dapps: [...dappArray], }), ], - { type: 'application/json' }, - ) - const updatedDappInfo = [new File([_blob], `dappInfo.json`)] - let newCID = await storeWithProgress(updatedDappInfo) - return newCID + { type: "application/json" } + ); + const updatedDappInfo = [new File([_blob], `dappInfo.json`)]; + let newCID = await storeWithProgress(updatedDappInfo); + return newCID; } async function storeWithProgress(files) { // show the root cid as soon as it's ready const onRootCidReady = (cid) => { - console.log('uploading files with cid:', cid) - } + console.log("uploading files with cid:", cid); + }; // when each chunk is stored, update the percentage complete and display - const totalSize = files.map((f) => f.size).reduce((a, b) => a + b, 0) - let uploaded = 0 + const totalSize = files.map((f) => f.size).reduce((a, b) => a + b, 0); + let uploaded = 0; const onStoredChunk = (size) => { - uploaded += size - const pct = 100 * (uploaded / totalSize) - } + uploaded += size; + const pct = 100 * (uploaded / totalSize); + }; - const client = makeStorageClient() - return client.put(files, { onRootCidReady, onStoredChunk }) + const client = makeStorageClient(); + return client.put(files, { onRootCidReady, onStoredChunk }); } function setStatus(message) { - let ele = document.getElementById('creationStatus') - var p_tag = document.createElement('p') - p_tag.key = `message${message}` - p_tag.textContent = '-> ' + message - ele.append(p_tag) + let ele = document.getElementById("creationStatus"); + var p_tag = document.createElement("p"); + p_tag.key = `message${message}`; + p_tag.textContent = "-> " + message; + ele.append(p_tag); } async function create_dapp() { if (dappImage == null) { - alert('Kindly upload an image') - return 0 + alert("Kindly upload an image"); + return 0; } - let WebsiteRentContract = websiteRentContract - let ifExists = await WebsiteRentContract.websiteExists(url) + let WebsiteRentContract = await getCustomNetworkWebsiteRentContract(NetworkChain,Web3ModalRef); + let ifExists = await WebsiteRentContract.websiteExists(url); if (!ifExists) { - setFormStep((prev) => prev + 1) - setStatus('Website Approved ๐Ÿฅณ ') - setStatus('Initiating Dapp Upload') - setStatus('Creating Dapp..') + setFormStep((prev) => prev + 1); + setStatus("Website Approved ๐Ÿฅณ "); + setStatus("Initiating Dapp Upload"); + setStatus("Creating Dapp.."); } else { - alert('Website URL Already Exists') - return 0 + alert("Website URL Already Exists"); + return 0; } - let _files = await makeDappFile() - let dappCid = await storeWithProgress(_files) + let _files = await makeDappFile(); + let dappCid = await storeWithProgress(_files); - let existingDapps = [...allDapps] - existingDapps.push(dappCid) - setAllDapps(existingDapps) - setStatus('Storing on IPFS...') + let existingDapps = [...allDapps]; + existingDapps.push(dappCid); + setAllDapps(existingDapps); + setStatus("Storing on IPFS..."); // ipfs storing part - let newCID = await StoreUpdatedDappsOnIpfs(existingDapps) - setStatus('Success on IPFS Storage ๐ŸŽ‰') - try { - setStatus('Storing on Smart contract !') + let newCID = await StoreUpdatedDappsOnIpfs(existingDapps); + setStatus("Success on IPFS Storage ๐ŸŽ‰"); + + setStatus("Storing on Smart contract !"); // smart contract part - let _price = parseEther(price) - console.log('Price to pay is ', _price) - setStatus('Uploading on Smart contract !') - setStatus('Kindly approve the Transaction') - let tx = await WebsiteRentContract.uploadWebsite( - url, - parseEther(price), - owner, - ) - setStatus('Transaction Mining.. ') - await tx.wait() - setStatus('Successfully Mined ๐ŸŽ‰') - setStatus('Uploading global IPFS Link ') - tx = await WebsiteRentContract.updateWebsitesIPFSLink(newCID) - setStatus('Transaction Mining.. ') - await tx.wait() - setStatus('Successfully storage ๐ŸŽ‰') - router.push('/Explore') - } catch (err) { - if (err.toString().includes('already exist')) { - alert('website already exists') - console.log(err) - return 0 - } else { - alert('open console to see error') - console.log('error :', err) + let _price = parseEther(price); + console.log("Price to pay is ", _price); + setStatus("Uploading on Smart contract !"); + setStatus("Kindly approve the Transaction"); + let signer = await getProviderOrSigner(NetworkChain, Web3ModalRef); + var options = { gasLimit: 120000}; + try{ + console.log("Arguments passing",{ + url,_price:parseInt(_price).toString(),owner,options + }) + let tx = await WebsiteRentContract.uploadWebsite( + url, + parseInt(_price).toString(), + owner, + options + ); + setStatus("Transaction Mining.. "); + await tx.wait(); + setStatus("Successfully Mined ๐ŸŽ‰"); + setStatus("Uploading global IPFS Link "); + try{ + let _tx = await WebsiteRentContract.updateWebsitesIPFSLink(newCID); + setStatus("Transaction Mining.. "); + await _tx.wait(); + setStatus("Successfully storage ๐ŸŽ‰"); + router.push("/Explore"); + + } + catch(e){ + console.log("ipfs link upload error") + } + } - } + catch(e){ + console.log("error in upload ",e); + } + } async function getUserInfo() { getProviderOrSigner(NetworkChain, Web3ModalRef, true).then((signer) => { - signer.getAddress().then(setOwner).catch(console.log) - }) + signer.getAddress().then(setOwner).catch(console.log); + }); } async function init() { - await getUserInfo() + await getUserInfo(); getCustomNetworkWebsiteRentContract( NetworkChain, Web3ModalRef, - setWebsiteRentContract, + setWebsiteRentContract ) .then(async (contract) => { - await getAllDappsUris(contract, setAllDapps) - setWebsiteRentContract(contract) + await getAllDappsUris(contract, setAllDapps); + setWebsiteRentContract(contract); }) .catch((e) => { - console.log('error in obtaining the contract ') - }) + console.log("error in obtaining the contract "); + }); } useEffect(() => { - init() - }, []) + init(); + }, []); return (
{formStep == 1 && ( <> - {' '} + {" "} - - - - {' '} + + + {" "} { - let res = e.target.value - setName(res) + let res = e.target.value; + setName(res); }} variant="outline" placeholder={"Let's have a cool name "} /> - - + + Dapp Type - type !== 'whitelist' && setType('whitelist') + type !== "whitelist" && setType("whitelist") } colorScheme="green" value="1" @@ -256,7 +264,7 @@ function CreateDapp(props) { Whitelist type !== 'sale' && setType('sale')} + onClick={() => type !== "sale" && setType("sale")} colorScheme="green" value="2" > @@ -266,17 +274,17 @@ function CreateDapp(props) { - - {' '} + + {" "} { - let res = e.target.value - if (res.toString().endsWith('/')) { - res = res.slice(0, -1) - console.log(res) + let res = e.target.value; + if (res.toString().endsWith("/")) { + res = res.slice(0, -1); + console.log(res); } - setUrl(res) + setUrl(res); }} variant="outline" defaultValue={url} @@ -284,35 +292,37 @@ function CreateDapp(props) { /> - - {' '} + + {" "} { - let res = e.target.value - setPrice(res) + let res = e.target.value; + setPrice(res); }} variant="outline" /> - - {' '} + + {" "} {}} - value="Currently we only support ETH" + onChange={(e) => { + setBlockchain(e.target.value); + }} + placeholder={"Ethereum , Tron"} /> - - {' '} + + {" "} { - let res = e.target.value - setOwner(res) + let res = e.target.value; + setOwner(res); }} variant="outline" defaultValue={owner} @@ -321,29 +331,29 @@ function CreateDapp(props) { { - setDappImage(URL.createObjectURL(event.target.files[0])) + setDappImage(URL.createObjectURL(event.target.files[0])); }} /> - + @@ -366,21 +376,21 @@ function CreateDapp(props) { )} - {formStep == 2 ? 'Dapp Upload Started' : ''} - + {formStep == 2 ? "Dapp Upload Started" : ""} + {formStep == 3 && ( @@ -390,7 +400,7 @@ function CreateDapp(props) { )}
- ) + ); } -export default CreateDapp +export default CreateDapp; diff --git a/pages/CreateSale.jsx b/pages/CreateSale.jsx index a4eeb4bc9f50..ec67be384eeb 100644 --- a/pages/CreateSale.jsx +++ b/pages/CreateSale.jsx @@ -217,7 +217,7 @@ function CreateSale() { {formStep == 1 && ( - + Create Sale diff --git a/pages/ExploreDapps.jsx b/pages/ExploreDapps.jsx index 8d03f430300c..097e71529ff5 100644 --- a/pages/ExploreDapps.jsx +++ b/pages/ExploreDapps.jsx @@ -49,7 +49,7 @@ function ExploreDapps(props) { async function Connect() { getProviderOrSigner(NetworkChain, web3ModalRef, true).then((signer) => { - signer.getAddress().then(async (user) => { + signer?.getAddress().then(async (user) => { console.log("user is ", user); fetchUserDeployments(user); setOwner(user); @@ -108,7 +108,7 @@ function ExploreDapps(props) { console.log("CIDs are ", cids); if (cids.length == 0) { setLoader(false); - } else fetchDappsContent(cids, setAllDapps, setLoader); + } else fetchDappsContent(cids, setAllDapps, setLoader,NetworkChain,web3ModalRef); }); setWebsiteRentContract(contract); }); @@ -117,14 +117,14 @@ function ExploreDapps(props) { useEffect(() => { init(); }, []); - +console.log("Filtered Dapps are ",filteredDapps) return ( <>
- Choose the Best Dapp that Suits your Vision + Rent Awesome Dapps like You prev + 1); } catch (e) { + console.log("\n\nNFT upload Error", e, "\n\n"); + setStatus("NFT Upload Error !"); + if (e.toString().includes("invalid token")) { setStatus("This NFT is not Minted by anyone", "red"); + setStatus(e.error?.message, "red"); + } else if ( + e.message.toString().includes("User denied transaction signature") + ) { + setStatus("You have rejected the transaction", "red"); + } else { + setStatus("You probably do not own the token", "red"); } - setStatus(e.error?.message, "red"); + setUploadError(true); } }); } @@ -428,7 +444,7 @@ function NftUpload(props) { )} {walletAddress && ( - + {formStep == 1 && ( uploadNFT()} title={"Upload NFT"} + disabled={shouldDisabled} /> @@ -502,12 +519,12 @@ function NftUpload(props) { bg={"black"} color={"white"} width={"100vw"} - paddingTop={"20vh"} + paddingTop={"2=10vh"} align={"center"} display={deployedAddress || formStep < 2 ? "none" : "flex"} > NFT Upload Status - + {" "} {loader && "Sale Creation Started.."} @@ -527,6 +544,19 @@ function NftUpload(props) { /> )} + {uploadError && ( + + + NFT is uploaded Unsuccessful + + + + )} )} diff --git a/pages/components/DappInformationPopup.jsx b/pages/components/DappInformationPopup.jsx index b1e11cd9875e..bcbac014513b 100644 --- a/pages/components/DappInformationPopup.jsx +++ b/pages/components/DappInformationPopup.jsx @@ -59,7 +59,7 @@ function DappInformationPopup(props) { - Price:{dapp.price} {dapp.currency} + Rent Price:{ dapp.rentPrice} {dapp.currency} Owned By:{dapp.owner.slice(0, 5)}.. @@ -113,7 +113,7 @@ function DappInformationPopup(props) { deployments={ dapp.type == "whitelist" ? whitelists : sales } - price={dapp.price} + price={dapp.rentPrice} selected={dapp.type == "whitelist" ? whitelists[0] : sales[0]} /> diff --git a/pages/components/DeploymentCard.jsx b/pages/components/DeploymentCard.jsx index e3c3bb89ca0f..d00b97b4950f 100644 --- a/pages/components/DeploymentCard.jsx +++ b/pages/components/DeploymentCard.jsx @@ -48,22 +48,22 @@ function DeploymentCard(props) { <> - + {item.name ? item.name : 'Fetching..'} diff --git a/pages/components/DropDownMenu.jsx b/pages/components/DropDownMenu.jsx index bf310a591d51..1a5a69938b14 100644 --- a/pages/components/DropDownMenu.jsx +++ b/pages/components/DropDownMenu.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { Menu, MenuItem, MenuButton, MenuList, Button } from "@chakra-ui/react"; import { ChevronDownIcon } from "@chakra-ui/icons"; import { useState } from "react"; @@ -10,11 +10,16 @@ function DropDownMenu(props) { let theme = { background: "white", textColor: "black" }; let selected = props.selected; function getMinimalAddress() { - let adr=props.selected; - if(!adr) - return "No Selected Option" + let adr = props.selected; + if (!adr) return "No Option Selected "; return adr.slice(0, 6) + ".." + adr.slice(40); } + + useEffect(() => { + selector(selected); + + }, []) + return ( } > - { getMinimalAddress()} + {!selected ? "Fetching.." : getMinimalAddress()} {options !== undefined && ( diff --git a/pages/components/IntegrateFrontend.jsx b/pages/components/IntegrateFrontend.jsx index fa632b09a346..8e0876a4b8b0 100644 --- a/pages/components/IntegrateFrontend.jsx +++ b/pages/components/IntegrateFrontend.jsx @@ -1,138 +1,197 @@ import { useEffect, useState } from "react"; -import { - ScaleFade, - VStack, - Heading, - Input, - HStack, -} from "@chakra-ui/react"; +import { ScaleFade, VStack, Heading, Input, HStack } from "@chakra-ui/react"; import NamedInput from "./NamedInput"; import LinkButton from "./LinkButton/LinkButton"; import DropDownMenu from "./DropDownMenu"; -import { WebsiteRentContract } from "../data/WebsiteRent"; import { parseEther } from "ethers/lib/utils"; +import { getCustomNetworkWebsiteRentContract } from "../data/WebsiteRent"; +import { useRef } from "react"; +import { getProviderOrSigner } from "../data/accountsConnection"; +import { getMinimalAddress } from "../../Utilities"; +let NetworkChain = "goerli"; function IntegrateFrontend(props) { let showToggle = props.showToggle; let _deployments = props.deployments; let _selectedOption = props.selected; let website = props.website; - let type=props.type; - let price=props.price; - console.log("props in integrate frinteened",props) - + let type = props.type; + let price = props.price; + const [formStep, setFormStep] = useState(1); const [websiteURL, setWebsiteURL] = useState(website); - const [selectedDeployment, setSelectedDeployment] = useState(_deployments[0]); + const [selectedDeployment, setSelectedDeployment] = useState(null); const [deployments, setDeployments] = useState(_deployments); const [numDays, setNumDays] = useState(1); + let web3ModalRef = useRef(); let bg = "black"; let textColor = "white"; + function setStatus(message) { + let ele = document.getElementById("creationStatus"); + var p_tag = document.createElement("p"); + p_tag.key = `message${message}`; + p_tag.textContent = "-> " + message; + ele.append(p_tag); + } async function integrate() { - alert("Started Renting.."); - + setFormStep((prev) => prev + 1); + setStatus("Renting Statrted โœ” "); + setStatus("Assembling arguments for upload .."); // need metamask sign on transaction - let websiteRentContract = WebsiteRentContract; + let websiteRentContract = await getCustomNetworkWebsiteRentContract( + NetworkChain, + web3ModalRef + ); + console.log("website rent contract ",websiteRentContract) let dayPrice = price; - let totalPrice = (dayPrice * numDays).toString(); - let days=parseInt(numDays); - console.log("price to pay", totalPrice) - console.log("renting with ", { - websiteURL, selectedDeployment, days - }) - let tx = await websiteRentContract.rentDapp(websiteURL, selectedDeployment,days,{ - value:parseEther(totalPrice) - }); + let totalPrice = dayPrice * numDays; + let days = parseInt(numDays); + // console.log("price to pay", totalPrice); + // console.log("renting with ", { + // websiteURL, + // selectedDeployment, + // days, + // }); - alert("Waiting for Transaction Mining...\nSee Console for Tx:Hash "); - console.log("Tx Hash is ", tx.hash); - await tx.wait(); - alert("FrontEnd is Integrated๐ŸŽ‰"); + // console.log("Selected Deply is ", selectedDeployment); + try { + if (!selectedDeployment) { + alert("select a deployment address first"); + return; + } + let signer = await getProviderOrSigner(NetworkChain, web3ModalRef); + let gasPrice = await signer.getGasPrice(); +// gasPrice = parseInt(gasPrice); + console.log("gasPrices are ", gasPrice); + setStatus("Making Dapp Rent Transaction"); + setStatus("Approve Transaction"); - } + var options = { + gasLimit: 3000000 , + value: parseEther(totalPrice.toString()), + }; + console.log("renting with ", { + websiteURL, + selectedDeployment, + days, + options, + }); + let tx = await websiteRentContract.rentDapp( + websiteURL, + selectedDeployment, + days, + options + ); + setStatus("Waiting for Transaction Completion"); + setStatus("Tx Hash is " + getMinimalAddress(tx.hash.toString())); + await tx.wait(); + setStatus("FrontEnd is Integrated๐ŸŽ‰"); + } catch (e) { + alert("Dapp renting failed , console for erros"); + console.log("Dapp rent failed ", e); + } + } return ( - - Rent a Dapp - - - { - { - console.log("slecting",val); - setSelectedDeployment(val) - } - } - options={_deployments} - selected={selectedDeployment} - /> - } - + {formStep == 1 && ( + + Rent a Dapp + + + { + { + setSelectedDeployment(val); + }} + options={_deployments} + selected={_deployments[0]} + /> + } + - - { - let res = e.target.value; - setWebsiteURL(res); - }} - variant="outline" - defaultValue={website} - placeholder="https://project.com" - /> - - - { - let res = e.target.value; - setNumDays(res); - }} - variant="outline" - placeholder="Days to rent for" - /> - - - - + + { + let res = e.target.value; + setWebsiteURL(res); + }} + variant="outline" + defaultValue={website} + placeholder="https://project.com" + /> + + + { + let res = e.target.value; + setNumDays(res); + }} + variant="outline" + placeholder="Days to rent for" + /> + + + + - - { - showToggle(null); - }} - /> - - + + { + showToggle(null); + }} + /> + + + + )} + + + {formStep == 2 ? "Dapp Renting Status" : ""} + + + {formStep == 3 && ( + + Successfully Published ๐Ÿฅณ + Click Here to see the uploaded + Dapps + + )} ); diff --git a/pages/components/LinkButton/LinkButton.jsx b/pages/components/LinkButton/LinkButton.jsx index f401bb3c3f4a..4b8b11c21359 100644 --- a/pages/components/LinkButton/LinkButton.jsx +++ b/pages/components/LinkButton/LinkButton.jsx @@ -10,6 +10,7 @@ function LinkButton({ loadingMessage, onClick, id, + disabled }) { const [navigate, setNavigate] = useState(false); const router = useRouter(); @@ -17,9 +18,11 @@ function LinkButton({ async function LetsNavigate(e) { router.push(href); } + let Key=id ? id : "button" + title; return ( diff --git a/pages/data/NftRenting.js b/pages/data/NftRenting.js index d117688dec53..5eee445f863d 100644 --- a/pages/data/NftRenting.js +++ b/pages/data/NftRenting.js @@ -1068,7 +1068,7 @@ const NftRentingTrackerABI = [ type: "function", }, ]; -const NftRentingTrackerAddress = "0xd376A218F94F8AF2425E6a82A5dd0FCb377DD4A3"; +const NftRentingTrackerAddress = "0xa60f56E187449a72074b3223ccf589f35cA7b857"; export const getCustomNetworkNFTFactoryContract = async ( network, diff --git a/pages/data/Sale.js b/pages/data/Sale.js index f9800647909c..d22e708f1c82 100644 --- a/pages/data/Sale.js +++ b/pages/data/Sale.js @@ -759,25 +759,27 @@ export const fetchSales = async ( try { getCustomNetworkSaleTrackerContract(NetworkChain, web3modalRef).then( async (TrackerContract) => { - console.log('fetching array of sales') + // console.log('fetching array of sales') await fetchSaleAddresses(TrackerContract, owner, arraySetter).then( async (Sales) => { let allSales = [] - console.log('iterating over') + // console.log('iterating over') Sales?.map(async (_Sale, index) => { - let SaleWebsite = await websiteRentContract.deploymentToWebsite( - _Sale, - ) - console.log('Sale website', SaleWebsite) - // let SaleContract = new ethers.Contract(_Sale, SaleABI, wallet) - console.log('sale is ', _Sale) + + let hostedWebsite=await websiteRentContract.deploymentToWebsite(_Sale); + let rentTime=await websiteRentContract.rentTime(hostedWebsite); + console.log("Hosted Sale website is_"+hostedWebsite+'_'+'for '+rentTime); + hostedWebsite=((rentTime*1000)> (new Date()).getTime())?hostedWebsite:null; + // console.log('Sale website', SaleWebsite) + // // let SaleContract = new ethers.Contract(_Sale, SaleABI, wallet) + // console.log('sale is ', _Sale) getCustomNetworkSaleContract( NetworkChain, web3modalRef, _Sale, ).then(async (SaleContract) => { - console.log('sale contract is ', SaleContract) + // console.log('sale contract is ', SaleContract) let name = await SaleContract.name() let symbol = await SaleContract.symbol() let baseURI = await SaleContract.baseURI() @@ -789,10 +791,12 @@ export const fetchSales = async ( symbol, baseURI, address: _Sale, - website: SaleWebsite, + website: hostedWebsite===""?null:hostedWebsite, startTime, endTime, owner, + rentTime:rentTime*1000, + } // console.log("Sale instance", SaleInstance); allSales.push(SaleInstance) @@ -801,7 +805,7 @@ export const fetchSales = async ( arraySetter(allSales) } } - console.log('returning') +// console.log('returning') return allSales }) }) diff --git a/pages/data/WebsiteRent.js b/pages/data/WebsiteRent.js index 738b1cd21938..b71e9da88e8e 100644 --- a/pages/data/WebsiteRent.js +++ b/pages/data/WebsiteRent.js @@ -1,6 +1,6 @@ import { getProviderOrSigner } from "./accountsConnection"; -export const WebsiteRentABI = [ +export const WebsiteRentABI =[ { "inputs": [ { @@ -250,10 +250,10 @@ export const WebsiteRentABI = [ } ] export const WebsiteRentBytecode = { - "object": "608060405260056008553480156200001657600080fd5b506040516200185c3803806200185c83398181016040528101906200003c91906200009b565b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505062000120565b600081519050620000958162000106565b92915050565b600060208284031215620000b457620000b362000101565b5b6000620000c48482850162000084565b91505092915050565b6000620000da82620000e1565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200011181620000cd565b81146200011d57600080fd5b50565b61172c80620001306000396000f3fe6080604052600436106100c25760003560e01c8063b290e8491161007f578063d642c82611610059578063d642c8261461029e578063daa89953146102db578063dc007f2814610304578063e6f28a4114610341576100c2565b8063b290e849146101fb578063be756b0814610224578063c0ede36014610261576100c2565b8063153b483f146100c75780631f473b471461010457806322bfaa011461012f57806328dc3e7e1461016c5780632ca64e4d14610195578063abc74174146101be575b600080fd5b3480156100d357600080fd5b506100ee60048036038101906100e99190610f61565b61035d565b6040516100fb9190611228565b60405180910390f35b34801561011057600080fd5b50610119610456565b604051610126919061125e565b60405180910390f35b34801561013b57600080fd5b5061015660048036038101906101519190610f61565b6104e4565b6040516101639190611228565b60405180910390f35b34801561017857600080fd5b50610193600480360381019061018e91906110e4565b61052d565b005b3480156101a157600080fd5b506101bc60048036038101906101b79190611075565b610591565b005b3480156101ca57600080fd5b506101e560048036038101906101e09190610f61565b61071c565b6040516101f29190611228565b60405180910390f35b34801561020757600080fd5b50610222600480360381019061021d9190610f61565b610765565b005b34801561023057600080fd5b5061024b60048036038101906102469190610f34565b6107d9565b604051610258919061125e565b60405180910390f35b34801561026d57600080fd5b5061028860048036038101906102839190610f61565b610879565b60405161029591906112e0565b60405180910390f35b3480156102aa57600080fd5b506102c560048036038101906102c09190610f61565b6108a7565b6040516102d291906112e0565b60405180910390f35b3480156102e757600080fd5b5061030260048036038101906102fd9190611019565b610983565b005b34801561031057600080fd5b5061032b60048036038101906103269190610f61565b610a8f565b6040516103389190611243565b60405180910390f35b61035b60048036038101906103569190610faa565b610ac5565b005b6000426003836040516103709190611211565b90815260200160405180910390205411156103cb576000826040516103959190611211565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610451565b60006003836040516103dd9190611211565b908152602001604051809103902081905550600080836040516104009190611211565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600090505b919050565b60068054610463906114e3565b80601f016020809104026020016040519081016040528092919081815260200182805461048f906114e3565b80156104dc5780601f106104b1576101008083540402835291602001916104dc565b820191906000526020600020905b8154815290600101906020018083116104bf57829003601f168201915b505050505081565b6005818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461058757600080fd5b8060088190555050565b600015156004846040516105a59190611211565b908152602001604051809103902060009054906101000a900460ff16151514610603576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fa906112c0565b60405180910390fd5b60016004846040516106159190611211565b908152602001604051809103902060006101000a81548160ff0219169083151502179055508060058460405161064b9190611211565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600080846040516106a89190611211565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550816002846040516107059190611211565b908152602001604051809103902081905550505050565b6000818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107bf57600080fd5b80600690805190602001906107d5929190610df7565b5050565b600160205280600052604060002060009150905080546107f8906114e3565b80601f0160208091040260200160405190810160405280929190818152602001828054610824906114e3565b80156108715780601f1061084657610100808354040283529160200191610871565b820191906000526020600020905b81548152906001019060200180831161085457829003601f168201915b505050505081565b6003818051602081018201805184825260208301602085012081835280955050505050506000915090505481565b6000816004816040516108ba9190611211565b908152602001604051809103902060009054906101000a900460ff16610915576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090c90611280565b60405180910390fd5b60006064600560028660405161092b9190611211565b90815260200160405180910390205461094491906113ff565b61094e91906113ce565b9050806002856040516109619190611211565b90815260200160405180910390205461097a9190611378565b92505050919050565b816004816040516109949190611211565b908152602001604051809103902060009054906101000a900460ff166109ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109e690611280565b60405180910390fd5b82600581604051610a009190611211565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a6657600080fd5b82600285604051610a779190611211565b90815260200160405180910390208190555050505050565b6004818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900460ff1681565b82600481604051610ad69190611211565b908152602001604051809103902060009054906101000a900460ff16610b31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2890611280565b60405180910390fd5b42600385604051610b429190611211565b90815260200160405180910390205410610b91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b88906112a0565b60405180910390fd5b600284604051610ba19190611211565b908152602001604051809103902054341015610bbc57600080fd5b8162015180610bcb91906113ff565b42610bd69190611378565b600385604051610be69190611211565b90815260200160405180910390208190555082600085604051610c099190611211565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190610ca8929190610df7565b50600060646005600287604051610cbf9190611211565b908152602001604051809103902054610cd891906113ff565b610ce291906113ce565b9050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610d4c573d6000803e3d6000fd5b50600585604051610d5d9190611211565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600287604051610db59190611211565b9081526020016040518091039020549081150290604051600060405180830381858888f19350505050158015610def573d6000803e3d6000fd5b505050505050565b828054610e03906114e3565b90600052602060002090601f016020900481019282610e255760008555610e6c565b82601f10610e3e57805160ff1916838001178555610e6c565b82800160010185558215610e6c579182015b82811115610e6b578251825591602001919060010190610e50565b5b509050610e799190610e7d565b5090565b5b80821115610e96576000816000905550600101610e7e565b5090565b6000610ead610ea884611320565b6112fb565b905082815260208101848484011115610ec957610ec8611607565b5b610ed48482856114a1565b509392505050565b600081359050610eeb816116c8565b92915050565b600082601f830112610f0657610f05611602565b5b8135610f16848260208601610e9a565b91505092915050565b600081359050610f2e816116df565b92915050565b600060208284031215610f4a57610f49611611565b5b6000610f5884828501610edc565b91505092915050565b600060208284031215610f7757610f76611611565b5b600082013567ffffffffffffffff811115610f9557610f9461160c565b5b610fa184828501610ef1565b91505092915050565b600080600060608486031215610fc357610fc2611611565b5b600084013567ffffffffffffffff811115610fe157610fe061160c565b5b610fed86828701610ef1565b9350506020610ffe86828701610edc565b925050604061100f86828701610f1f565b9150509250925092565b600080604083850312156110305761102f611611565b5b600083013567ffffffffffffffff81111561104e5761104d61160c565b5b61105a85828601610ef1565b925050602061106b85828601610f1f565b9150509250929050565b60008060006060848603121561108e5761108d611611565b5b600084013567ffffffffffffffff8111156110ac576110ab61160c565b5b6110b886828701610ef1565b93505060206110c986828701610f1f565b92505060406110da86828701610edc565b9150509250925092565b6000602082840312156110fa576110f9611611565b5b600061110884828501610f1f565b91505092915050565b61111a81611459565b82525050565b6111298161146b565b82525050565b600061113a82611351565b611144818561135c565b93506111548185602086016114b0565b61115d81611616565b840191505092915050565b600061117382611351565b61117d818561136d565b935061118d8185602086016114b0565b80840191505092915050565b60006111a660278361135c565b91506111b182611627565b604082019050919050565b60006111c960198361135c565b91506111d482611676565b602082019050919050565b60006111ec60168361135c565b91506111f78261169f565b602082019050919050565b61120b81611497565b82525050565b600061121d8284611168565b915081905092915050565b600060208201905061123d6000830184611111565b92915050565b60006020820190506112586000830184611120565b92915050565b60006020820190508181036000830152611278818461112f565b905092915050565b6000602082019050818103600083015261129981611199565b9050919050565b600060208201905081810360008301526112b9816111bc565b9050919050565b600060208201905081810360008301526112d9816111df565b9050919050565b60006020820190506112f56000830184611202565b92915050565b6000611305611316565b90506113118282611515565b919050565b6000604051905090565b600067ffffffffffffffff82111561133b5761133a6115d3565b5b61134482611616565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600061138382611497565b915061138e83611497565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113c3576113c2611546565b5b828201905092915050565b60006113d982611497565b91506113e483611497565b9250826113f4576113f3611575565b5b828204905092915050565b600061140a82611497565b915061141583611497565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561144e5761144d611546565b5b828202905092915050565b600061146482611477565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156114ce5780820151818401526020810190506114b3565b838111156114dd576000848401525b50505050565b600060028204905060018216806114fb57607f821691505b6020821081141561150f5761150e6115a4565b5b50919050565b61151e82611616565b810181811067ffffffffffffffff8211171561153d5761153c6115d3565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f546865205765627369746520646f6573206e6f74206578697374206f6e20486f60008201527f73744d794e465400000000000000000000000000000000000000000000000000602082015250565b7f5765627369746520697320616c72656164792072656e74656400000000000000600082015250565b7f7765627369746520616c72656164792065786973747300000000000000000000600082015250565b6116d181611459565b81146116dc57600080fd5b50565b6116e881611497565b81146116f357600080fd5b5056fea26469706673582212204010304fadcbcab129de5e525199496f369bb3915e8883e92aa606657c5c5b0564736f6c63430008070033", - + "object": "608060405260056008553480156200001657600080fd5b50604051620018a2380380620018a283398181016040528101906200003c91906200009b565b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505062000120565b600081519050620000958162000106565b92915050565b600060208284031215620000b457620000b362000101565b5b6000620000c48482850162000084565b91505092915050565b6000620000da82620000e1565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200011181620000cd565b81146200011d57600080fd5b50565b61177280620001306000396000f3fe6080604052600436106100c25760003560e01c8063b290e8491161007f578063d642c82611610059578063d642c8261461029e578063daa89953146102db578063dc007f2814610304578063e6f28a4114610341576100c2565b8063b290e849146101fb578063be756b0814610224578063c0ede36014610261576100c2565b8063153b483f146100c75780631f473b471461010457806322bfaa011461012f57806328dc3e7e1461016c5780632ca64e4d14610195578063abc74174146101be575b600080fd5b3480156100d357600080fd5b506100ee60048036038101906100e99190610f3b565b61035d565b6040516100fb9190611225565b60405180910390f35b34801561011057600080fd5b50610119610456565b604051610126919061125b565b60405180910390f35b34801561013b57600080fd5b5061015660048036038101906101519190610f3b565b6104e4565b6040516101639190611225565b60405180910390f35b34801561017857600080fd5b50610193600480360381019061018e91906110be565b61052d565b005b3480156101a157600080fd5b506101bc60048036038101906101b7919061104f565b610591565b005b3480156101ca57600080fd5b506101e560048036038101906101e09190610f3b565b61071c565b6040516101f29190611225565b60405180910390f35b34801561020757600080fd5b50610222600480360381019061021d9190610f3b565b610765565b005b34801561023057600080fd5b5061024b60048036038101906102469190610f0e565b61077f565b604051610258919061125b565b60405180910390f35b34801561026d57600080fd5b5061028860048036038101906102839190610f3b565b61081f565b60405161029591906112fd565b60405180910390f35b3480156102aa57600080fd5b506102c560048036038101906102c09190610f3b565b61084d565b6040516102d291906112fd565b60405180910390f35b3480156102e757600080fd5b5061030260048036038101906102fd9190610ff3565b610929565b005b34801561031057600080fd5b5061032b60048036038101906103269190610f3b565b610a35565b6040516103389190611240565b60405180910390f35b61035b60048036038101906103569190610f84565b610a6b565b005b600042600383604051610370919061120e565b90815260200160405180910390205411156103cb57600082604051610395919061120e565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610451565b60006003836040516103dd919061120e565b90815260200160405180910390208190555060008083604051610400919061120e565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600090505b919050565b6006805461046390611500565b80601f016020809104026020016040519081016040528092919081815260200182805461048f90611500565b80156104dc5780601f106104b1576101008083540402835291602001916104dc565b820191906000526020600020905b8154815290600101906020018083116104bf57829003601f168201915b505050505081565b6005818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461058757600080fd5b8060088190555050565b600015156004846040516105a5919061120e565b908152602001604051809103902060009054906101000a900460ff16151514610603576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fa906112dd565b60405180910390fd5b6001600484604051610615919061120e565b908152602001604051809103902060006101000a81548160ff0219169083151502179055508060058460405161064b919061120e565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600080846040516106a8919061120e565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600284604051610705919061120e565b908152602001604051809103902081905550505050565b6000818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b806006908051906020019061077b929190610dd1565b5050565b6001602052806000526040600020600091509050805461079e90611500565b80601f01602080910402602001604051908101604052809291908181526020018280546107ca90611500565b80156108175780601f106107ec57610100808354040283529160200191610817565b820191906000526020600020905b8154815290600101906020018083116107fa57829003601f168201915b505050505081565b6003818051602081018201805184825260208301602085012081835280955050505050506000915090505481565b600081600481604051610860919061120e565b908152602001604051809103902060009054906101000a900460ff166108bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b29061127d565b60405180910390fd5b6000606460056002866040516108d1919061120e565b9081526020016040518091039020546108ea919061141c565b6108f491906113eb565b905080600285604051610907919061120e565b9081526020016040518091039020546109209190611395565b92505050919050565b8160048160405161093a919061120e565b908152602001604051809103902060009054906101000a900460ff16610995576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098c9061127d565b60405180910390fd5b826005816040516109a6919061120e565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a0c57600080fd5b82600285604051610a1d919061120e565b90815260200160405180910390208190555050505050565b6004818051602081018201805184825260208301602085012081835280955050505050506000915054906101000a900460ff1681565b82600481604051610a7c919061120e565b908152602001604051809103902060009054906101000a900460ff16610ad7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ace9061127d565b60405180910390fd5b42600385604051610ae8919061120e565b90815260200160405180910390205410610b37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2e906112bd565b60405180910390fd5b600284604051610b47919061120e565b908152602001604051809103902054341015610b98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8f9061129d565b60405180910390fd5b81603c610ba5919061141c565b42610bb09190611395565b600385604051610bc0919061120e565b90815260200160405180910390208190555082600085604051610be3919061120e565b908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190610c82929190610dd1565b50600060646005600287604051610c99919061120e565b908152602001604051809103902054610cb2919061141c565b610cbc91906113eb565b9050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610d26573d6000803e3d6000fd5b50600585604051610d37919061120e565b908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600287604051610d8f919061120e565b9081526020016040518091039020549081150290604051600060405180830381858888f19350505050158015610dc9573d6000803e3d6000fd5b505050505050565b828054610ddd90611500565b90600052602060002090601f016020900481019282610dff5760008555610e46565b82601f10610e1857805160ff1916838001178555610e46565b82800160010185558215610e46579182015b82811115610e45578251825591602001919060010190610e2a565b5b509050610e539190610e57565b5090565b5b80821115610e70576000816000905550600101610e58565b5090565b6000610e87610e828461133d565b611318565b905082815260208101848484011115610ea357610ea2611624565b5b610eae8482856114be565b509392505050565b600081359050610ec58161170e565b92915050565b600082601f830112610ee057610edf61161f565b5b8135610ef0848260208601610e74565b91505092915050565b600081359050610f0881611725565b92915050565b600060208284031215610f2457610f2361162e565b5b6000610f3284828501610eb6565b91505092915050565b600060208284031215610f5157610f5061162e565b5b600082013567ffffffffffffffff811115610f6f57610f6e611629565b5b610f7b84828501610ecb565b91505092915050565b600080600060608486031215610f9d57610f9c61162e565b5b600084013567ffffffffffffffff811115610fbb57610fba611629565b5b610fc786828701610ecb565b9350506020610fd886828701610eb6565b9250506040610fe986828701610ef9565b9150509250925092565b6000806040838503121561100a5761100961162e565b5b600083013567ffffffffffffffff81111561102857611027611629565b5b61103485828601610ecb565b925050602061104585828601610ef9565b9150509250929050565b6000806000606084860312156110685761106761162e565b5b600084013567ffffffffffffffff81111561108657611085611629565b5b61109286828701610ecb565b93505060206110a386828701610ef9565b92505060406110b486828701610eb6565b9150509250925092565b6000602082840312156110d4576110d361162e565b5b60006110e284828501610ef9565b91505092915050565b6110f481611476565b82525050565b61110381611488565b82525050565b60006111148261136e565b61111e8185611379565b935061112e8185602086016114cd565b61113781611633565b840191505092915050565b600061114d8261136e565b611157818561138a565b93506111678185602086016114cd565b80840191505092915050565b6000611180602683611379565b915061118b82611644565b604082019050919050565b60006111a3601783611379565b91506111ae82611693565b602082019050919050565b60006111c6601983611379565b91506111d1826116bc565b602082019050919050565b60006111e9601683611379565b91506111f4826116e5565b602082019050919050565b611208816114b4565b82525050565b600061121a8284611142565b915081905092915050565b600060208201905061123a60008301846110eb565b92915050565b600060208201905061125560008301846110fa565b92915050565b600060208201905081810360008301526112758184611109565b905092915050565b6000602082019050818103600083015261129681611173565b9050919050565b600060208201905081810360008301526112b681611196565b9050919050565b600060208201905081810360008301526112d6816111b9565b9050919050565b600060208201905081810360008301526112f6816111dc565b9050919050565b600060208201905061131260008301846111ff565b92915050565b6000611322611333565b905061132e8282611532565b919050565b6000604051905090565b600067ffffffffffffffff821115611358576113576115f0565b5b61136182611633565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b60006113a0826114b4565b91506113ab836114b4565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113e0576113df611563565b5b828201905092915050565b60006113f6826114b4565b9150611401836114b4565b92508261141157611410611592565b5b828204905092915050565b6000611427826114b4565b9150611432836114b4565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561146b5761146a611563565b5b828202905092915050565b600061148182611494565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156114eb5780820151818401526020810190506114d0565b838111156114fa576000848401525b50505050565b6000600282049050600182168061151857607f821691505b6020821081141561152c5761152b6115c1565b5b50919050565b61153b82611633565b810181811067ffffffffffffffff8211171561155a576115596115f0565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f546865205765627369746520646f6573206e6f74206578697374206f6e20526560008201527f6e74576562330000000000000000000000000000000000000000000000000000602082015250565b7f496e73756666696369656e742046756e64732053656e74000000000000000000600082015250565b7f5765627369746520697320616c72656164792072656e74656400000000000000600082015250565b7f7765627369746520616c72656164792065786973747300000000000000000000600082015250565b61171781611476565b811461172257600080fd5b50565b61172e816114b4565b811461173957600080fd5b5056fea264697066735822122086af4cf6c32b0a017b7d3048d170a61dc2185037189171bb4f11d4667f5f20e364736f6c63430008070033", + } -export const WebsiteRentAddress = "0x88913a6bc717731820D9ba09f40e2d9CA9D85E7d"; +export const WebsiteRentAddress = "0x88EB541CcDF2Ba00335624a14177B20319e6b7d7"; const ethers = require("ethers"); let Network = "goerli"; diff --git a/pages/data/Whitelist.js b/pages/data/Whitelist.js index 510cf99384d8..87fa39527dae 100644 --- a/pages/data/Whitelist.js +++ b/pages/data/Whitelist.js @@ -1,4 +1,4 @@ -import { WebsiteRentContract } from "./WebsiteRent"; +import { getCustomNetworkWebsiteRentContract, WebsiteRentContract } from "./WebsiteRent"; import { getProviderOrSigner } from "./accountsConnection"; export const whitelistABI = [ { @@ -359,56 +359,67 @@ export const fetchWhitelists = async ( ) => { // console.log("obtaining whitelists for ", owner); - console.log("fetching whitelists"); - getCustomNetworkWhitelistTrackerContract(NetworkChain, web3modalRef).then( - async (TrackerContract) => { - await fetchWhitelistAddresses(TrackerContract, owner, arraySetter).then( - async (whitelists) => { - let allWhitelists = []; - console.log("iterating over"); - whitelists.map(async (_whitelist, index) => { - let whitelistContract = await getCustomNetworkWhitelistContract( - NetworkChain, - web3modalRef, - _whitelist - ); + // console.log("fetching whitelists"); + let websiteRentContract = await getCustomNetworkWebsiteRentContract( + NetworkChain, + web3modalRef + ); + let whitelistTracker = await getCustomNetworkWhitelistTrackerContract( + NetworkChain, + web3modalRef + ); + - let hostedWebsite = await TrackerContract.deploymentToWebsite( - _whitelist - ); - let name = await whitelistContract.name(); - let symbol = await whitelistContract.symbol(); - let baseURI = await whitelistContract.baseURI(); - let whitelistedCount = - await whitelistContract.numAddressesWhitelisted(); - let startTime = await whitelistContract.startTime(); - let endTime = await whitelistContract.endTime(); - let whitelistInstance = { - id: index + 1, - name, - symbol, - baseURI, - address: _whitelist, - website: hostedWebsite, - users: whitelistedCount, - startTime, - endTime, - owner, - }; - // console.log("whitelist instance", whitelistInstance); - allWhitelists.push(whitelistInstance); - if (index + 1 == whitelists.length) { - if (arraySetter != undefined) { - arraySetter(allWhitelists); - } - } - }); - console.log("returning"); - return allWhitelists; - } - ); - } + let whitelists = await fetchWhitelistAddresses( + whitelistTracker, + owner, + arraySetter ); + // console.log("all whitelists are ",whitelists); + let allWhitelists = []; + // console.log("iterating over"); + whitelists.map(async (_whitelist, index) => { + let whitelistContract = await getCustomNetworkWhitelistContract( + NetworkChain, + web3modalRef, + _whitelist + ); + + let hostedWebsite=await websiteRentContract.deploymentToWebsite(_whitelist); + let rentTime=await websiteRentContract.rentTime(hostedWebsite); + console.log("Hosted Whitelist website is_"+hostedWebsite+'_'+'for '+rentTime); + hostedWebsite=((rentTime*1000)> (new Date()).getTime())?hostedWebsite:null; + + let name = await whitelistContract.name(); + let symbol = await whitelistContract.symbol(); + let baseURI = await whitelistContract.baseURI(); + let whitelistedCount = await whitelistContract.numAddressesWhitelisted(); + let startTime = await whitelistContract.startTime(); + let endTime = await whitelistContract.endTime(); + let whitelistInstance = { + id: index + 1, + name, + symbol, + baseURI, + address: _whitelist, + website: hostedWebsite===""?null:hostedWebsite, + users: whitelistedCount, + startTime, + endTime, + owner, + rentTime:rentTime*1000, + + }; + console.log("whitelist instance", whitelistInstance); + allWhitelists.push(whitelistInstance); + if (index + 1 == whitelists.length) { + if (arraySetter != undefined) { + arraySetter(allWhitelists); + } + } + }); + // console.log("returning"); + return allWhitelists; }; export const getCustomNetworkWhitelistContract = async ( diff --git a/pages/data/ipfsStuff.js b/pages/data/ipfsStuff.js index 3892e93a4be6..6f5100873fdd 100644 --- a/pages/data/ipfsStuff.js +++ b/pages/data/ipfsStuff.js @@ -1,4 +1,4 @@ -import { websiteRentContract } from "./WebsiteRent"; +import { getCustomNetworkWebsiteRentContract, websiteRentContract } from "./WebsiteRent"; const axios = require("axios"); export const getAllDappsUris = async (contract, setter) => { @@ -45,7 +45,7 @@ export const getTokensMetaData = async (tokenURIs, setter) => { }); }); }; -export const fetchDappsContent = async (Cids, setter, loader) => { +export const fetchDappsContent = async (Cids, setter, loader,NetworkChain,web3modalRef) => { let dappArray = []; await Cids.map(async (cid, index) => { let _link = `https://${cid}.ipfs.w3s.link/metadata.json`; @@ -53,7 +53,10 @@ export const fetchDappsContent = async (Cids, setter, loader) => { let dapp = response.data; dapp.image = getImageLinkFromIPFS(dapp.image); if (dapp.url) { + let websiteRentContract=await getCustomNetworkWebsiteRentContract(NetworkChain,web3modalRef) let renttime = await websiteRentContract.rentTime(dapp.url); + let rentPrice = await websiteRentContract.getDappRentPrice(dapp.url); + dapp.rentPrice=parseFloat(rentPrice/(10**18)); if (parseInt(renttime) * 1000 > new Date().getTime()) { console.log("rented already !"); dapp.rented = true; @@ -62,6 +65,7 @@ export const fetchDappsContent = async (Cids, setter, loader) => { dapp.rented = false; } } + console.log("Dapp is ",dapp); dappArray.push(dapp); if (setter != undefined && index + 1 == Cids.length) { @@ -70,7 +74,9 @@ export const fetchDappsContent = async (Cids, setter, loader) => { loader(false); return dappArray; } + }); + return dappArray; }; export function getImageLinkFromIPFS(cid) { let link = `https://${cid}.ipfs.w3s.link/img.PNG`; From 016fd3c7211fec36f16057ca14289fc8b0797010 Mon Sep 17 00:00:00 2001 From: umaresso Date: Sun, 6 Nov 2022 13:47:24 +0500 Subject: [PATCH 2/3] nft renting working --- pages/ExploreNfts.jsx | 70 ++++++++++++++++++++------------- pages/NftUpload.jsx | 18 +++++---- pages/components/NftDetails.jsx | 10 ++--- pages/data/ipfsStuff.js | 34 ++++++++++------ 4 files changed, 81 insertions(+), 51 deletions(-) diff --git a/pages/ExploreNfts.jsx b/pages/ExploreNfts.jsx index e156046c82d9..ddecc8b45f60 100644 --- a/pages/ExploreNfts.jsx +++ b/pages/ExploreNfts.jsx @@ -38,7 +38,7 @@ export async function getStaticProps(context) { function ExploreNfts(props) { const [currentMenu, setCurrentMenu] = useState("all"); - const [owner, setOwner] = useState(null); + const [walletAddress, setWalletAddress] = useState(null); const [selectedNft, setSelectedNft] = useState(null); const [NftRentingTracker, setNftRentingTracker] = useState(null); const [loading, setLoading] = useState(false); @@ -93,13 +93,13 @@ function ExploreNfts(props) { getProviderOrSigner(NetworkChain, web3ModalRef, true).then((signer) => { if (signer) { signer.getAddress().then((user) => { - setOwner(user); + setWalletAddress(user); }); } }); } async function init() { - if (!owner) return; + if (!walletAddress) return; let allNFTs = []; let trackerContract = await getCustomNetworkNFTTrackerContract( NetworkChain, @@ -112,6 +112,10 @@ function ExploreNfts(props) { console.log("All contract tokens are ", allContractsTokens); let indexer = 0; + if (contractsArray.length == 0) { + setLoading(false); + return 0; + } contractsArray?.map(async (contractAddress, contractsAddressIndex) => { let thisContractTokens = allContractsTokens[contractAddress]; let rentableContractAddress = await getRentableContract( @@ -172,26 +176,32 @@ function ExploreNfts(props) { useEffect(() => { setLoading(true); + init(); - }, [owner]); + }, [walletAddress]); // console.log("NFTs are", NFTs); let filteredNfts = []; - NFTs?.map((nft) => { - if ( - currentMenu === "all" || - (currentMenu == "rented" && nft.rented) || - (currentMenu == "available" && !nft.rented) || - (currentMenu == "mine" && (nft.owner == owner || nft.user == owner)) - ) { - filteredNfts.push(nft); - } - }); + if (currentMenu === "all") { + filteredNfts = NFTs; + } else { + NFTs?.map((nft) => { + if ( + (currentMenu == "rented" && nft.rented) || + (currentMenu == "available" && !nft.rented) || + (currentMenu == "mine" && + (nft.owner == walletAddress || nft.user == walletAddress)) + ) { + filteredNfts.push(nft); + } + }); + } + console.log("NFTs are", NFTs); console.log("filtered NFT are", filteredNfts); return ( <> - {owner == null && ( + {walletAddress == null && ( )} - {owner != null && ( + {walletAddress != null && ( <> 0 ? "fit-content" : "100vh"} @@ -216,13 +226,14 @@ function ExploreNfts(props) { bg="black" textColor={"white"} width={"100%"} + paddingBottom={"5vh"} > -
- +
+ Rent cool NFTs @@ -230,7 +241,7 @@ function ExploreNfts(props) { fontFamily={"sans-serif"} textColor={"grey"} fontSize={"18px"} - width={["80vw", "70vw", "60vw"]} + width={["80vw", "70vw", "40vw"]} > RentWeb3 is your favorite place to rent awesome NFTs to use in your Next game , for attending an event or hosting your @@ -273,13 +284,13 @@ function ExploreNfts(props) { )} - + {filteredNfts?.map((nft) => { return ( @@ -294,10 +305,15 @@ function ExploreNfts(props) { {!loading && filteredNfts.length == 0 && ( - - No Collections for Category{" "} - {`"${currentMenu.toLocaleUpperCase()}"`} - +
+ + {currentMenu == "all" + ? "No Collections to Display" + : `No Collections for Category + "${currentMenu.toLocaleUpperCase()}" + `} + +
)}
diff --git a/pages/NftUpload.jsx b/pages/NftUpload.jsx index 2f5b46d8161a..6261413d1e0a 100644 --- a/pages/NftUpload.jsx +++ b/pages/NftUpload.jsx @@ -62,7 +62,7 @@ function NftUpload(props) { const [factoryContract, setFactoryContract] = useState(null); const [NftRentingTracker, setNftRentingTracker] = useState(null); const [walletAddress, setWalletAddress] = useState(null); - const [deployedAddress, setDeployedAddress] = useState(null); + const [nftUploaded, setNftUploaded] = useState(null); const [loader, setLoader] = useState(false); const [contractAddresses, setContractAddresses] = useState(null); const [contractTokens, setContractTokens] = useState(null); @@ -291,7 +291,7 @@ function NftUpload(props) { setStatus("Approve Transaction"); let options = { - gasLimit: 200000, + gasLimit: 300000, }; let tx = await contract.uploadNftForRent( @@ -305,9 +305,8 @@ function NftUpload(props) { ); setStatus("Waiting for Transaction Completion.."); await tx.wait(); - setDeployedAddress(deployedContractAddress); - setFormStep((prev) => prev + 1); + setNftUploaded(true); } catch (e) { console.log("\n\nNFT upload Error", e, "\n\n"); @@ -509,7 +508,7 @@ function NftUpload(props) { variant={"solid"} onClick={() => uploadNFT()} title={"Upload NFT"} - disabled={shouldDisabled} + /> @@ -521,7 +520,7 @@ function NftUpload(props) { width={"100vw"} paddingTop={"2=10vh"} align={"center"} - display={deployedAddress || formStep < 2 ? "none" : "flex"} + display={nftUploaded || formStep < 2 ? "none" : "flex"} > NFT Upload Status @@ -530,8 +529,7 @@ function NftUpload(props) { {loader && "Sale Creation Started.."} - - {deployedAddress !== null && ( + { (nftUploaded || (!uploadError && formStep==3) ) && ( NFT is uploaded Successfully ๐Ÿฅณ @@ -557,6 +555,10 @@ function NftUpload(props) { /> )} + + + + )} diff --git a/pages/components/NftDetails.jsx b/pages/components/NftDetails.jsx index cf41bbb5f40b..5d66b19b16cd 100644 --- a/pages/components/NftDetails.jsx +++ b/pages/components/NftDetails.jsx @@ -47,7 +47,7 @@ function NftDetails({ NFT, selector }) { return ( selector(Nft)} height={"fit-content"} key={Key}> - - + + Token # {Nft.id} {!Nft.rented ? ( - ) : ( - )} diff --git a/pages/data/ipfsStuff.js b/pages/data/ipfsStuff.js index 6f5100873fdd..b75ce0eb7346 100644 --- a/pages/data/ipfsStuff.js +++ b/pages/data/ipfsStuff.js @@ -1,4 +1,7 @@ -import { getCustomNetworkWebsiteRentContract, websiteRentContract } from "./WebsiteRent"; +import { + getCustomNetworkWebsiteRentContract, + websiteRentContract, +} from "./WebsiteRent"; const axios = require("axios"); export const getAllDappsUris = async (contract, setter) => { @@ -19,8 +22,9 @@ export const getAllDappsUris = async (contract, setter) => { }; function embedGateway(hash) { if (hash.toString().startsWith("http")) return hash; - console.log("Embedding gateway with ", hash); - return "https://ipfs.io/ipfs//" + hash; + + let link = "https://gateway.pinata.cloud/ipfs/" + hash; + return link; } export const getTokenMetadata = async (tokenUriHash) => { @@ -45,7 +49,13 @@ export const getTokensMetaData = async (tokenURIs, setter) => { }); }); }; -export const fetchDappsContent = async (Cids, setter, loader,NetworkChain,web3modalRef) => { +export const fetchDappsContent = async ( + Cids, + setter, + loader, + NetworkChain, + web3modalRef +) => { let dappArray = []; await Cids.map(async (cid, index) => { let _link = `https://${cid}.ipfs.w3s.link/metadata.json`; @@ -53,10 +63,13 @@ export const fetchDappsContent = async (Cids, setter, loader,NetworkChain,web3mo let dapp = response.data; dapp.image = getImageLinkFromIPFS(dapp.image); if (dapp.url) { - let websiteRentContract=await getCustomNetworkWebsiteRentContract(NetworkChain,web3modalRef) + let websiteRentContract = await getCustomNetworkWebsiteRentContract( + NetworkChain, + web3modalRef + ); let renttime = await websiteRentContract.rentTime(dapp.url); let rentPrice = await websiteRentContract.getDappRentPrice(dapp.url); - dapp.rentPrice=parseFloat(rentPrice/(10**18)); + dapp.rentPrice = parseFloat(rentPrice / 10 ** 18); if (parseInt(renttime) * 1000 > new Date().getTime()) { console.log("rented already !"); dapp.rented = true; @@ -65,7 +78,7 @@ export const fetchDappsContent = async (Cids, setter, loader,NetworkChain,web3mo dapp.rented = false; } } - console.log("Dapp is ",dapp); + console.log("Dapp is ", dapp); dappArray.push(dapp); if (setter != undefined && index + 1 == Cids.length) { @@ -74,7 +87,6 @@ export const fetchDappsContent = async (Cids, setter, loader,NetworkChain,web3mo loader(false); return dappArray; } - }); return dappArray; }; @@ -128,9 +140,9 @@ export const getAllContractTokens = async (contract, setter) => { } }; export function getIpfsImageLink(_link) { - if (_link.toString().startsWith("ipfs:")) { - let Cid = _link.toString().slice(5); - let link = "https://ipfs.io/ipfs/" + Cid; + if (_link.toString().startsWith("ipfs://")) { + let Cid = _link.toString().slice(7); + let link = "https://gateway.pinata.cloud/ipfs/" + Cid; return link; } return _link; From e12f4b07e18bdcffc6006a9ad4c40f879d40fb3c Mon Sep 17 00:00:00 2001 From: umaresso Date: Sun, 6 Nov 2022 13:55:58 +0500 Subject: [PATCH 3/3] tested dapp rent on local --- pages/CreateDapp.jsx | 2 +- pages/components/DropDownMenu.jsx | 2 +- pages/components/IntegrateFrontend.jsx | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pages/CreateDapp.jsx b/pages/CreateDapp.jsx index da24cb7a4dd6..bf3f9716272f 100644 --- a/pages/CreateDapp.jsx +++ b/pages/CreateDapp.jsx @@ -158,7 +158,7 @@ function CreateDapp(props) { setStatus("Uploading on Smart contract !"); setStatus("Kindly approve the Transaction"); let signer = await getProviderOrSigner(NetworkChain, Web3ModalRef); - var options = { gasLimit: 120000}; + var options = { gasLimit: 300000}; try{ console.log("Arguments passing",{ url,_price:parseInt(_price).toString(),owner,options diff --git a/pages/components/DropDownMenu.jsx b/pages/components/DropDownMenu.jsx index 1a5a69938b14..8bbd828f9ce4 100644 --- a/pages/components/DropDownMenu.jsx +++ b/pages/components/DropDownMenu.jsx @@ -30,7 +30,7 @@ function DropDownMenu(props) { as={Button} rightIcon={} > - {!selected ? "Fetching.." : getMinimalAddress()} + { getMinimalAddress()} {options !== undefined && ( diff --git a/pages/components/IntegrateFrontend.jsx b/pages/components/IntegrateFrontend.jsx index 8e0876a4b8b0..93403dac2a37 100644 --- a/pages/components/IntegrateFrontend.jsx +++ b/pages/components/IntegrateFrontend.jsx @@ -67,7 +67,6 @@ function IntegrateFrontend(props) { console.log("gasPrices are ", gasPrice); setStatus("Making Dapp Rent Transaction"); setStatus("Approve Transaction"); - var options = { gasLimit: 3000000 , value: parseEther(totalPrice.toString()),