From aab097f6a755c56469d8ad53f014eb0005feade6 Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Wed, 4 Jan 2023 15:10:40 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=F0=9F=94=AD=20=E2=86=9D=20Updating?= =?UTF-8?q?=20route=20for=20lazy=20minting=20proposal=20data=20as=20nfts?= =?UTF-8?q?=20(check=20prev=20commit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/app.py | 8 ++++++++ Server/frontend/components/Sidebar.jsx | 2 +- .../api/proposals}/constants/index.ts | 2 +- .../{ => pages/api/proposals}/context/index.jsx | 0 .../pages/api/proposals/fetchProposals.js | 17 +++++++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) rename Server/frontend/{ => pages/api/proposals}/constants/index.ts (94%) rename Server/frontend/{ => pages/api/proposals}/context/index.jsx (100%) diff --git a/Server/app.py b/Server/app.py index 9d5df823..586f2ec8 100644 --- a/Server/app.py +++ b/Server/app.py @@ -11,12 +11,20 @@ contract = web3Sdk.get_contract("0xCcaA1ABA77Bae6296D386C2F130c46FEc3E5A004") proposals = contract.call("getProposals") +# Minting candidate nfts +nftSdk = ThirdwebSDK('mumbai') +nftContract = nftSdk.get_contract("0xed6e837Fda815FBf78E8E7266482c5Be80bC4bF9") + @app.route('/') def index(): return "Hello World" @app.route('/proposals', methods=["GET"]) def getProposals(): + # Mint nft based on proposal id + proposalCandidate = nftContract.call("lazyMint", _amount, _baseURIForTokens, _data) # Get this from Jupyter notebook -> https://thirdweb.com/mumbai/0xed6e837Fda815FBf78E8E7266482c5Be80bC4bF9/nfts token id 0 (e.g.) + createProposal = contract.call("createProposal", _owner, _title, _description, _target, _deadline, _image) # Get this from PUSH req contents + return proposals @app.route('/login', methods=['POST']) diff --git a/Server/frontend/components/Sidebar.jsx b/Server/frontend/components/Sidebar.jsx index c4635f66..4e4c8ab0 100644 --- a/Server/frontend/components/Sidebar.jsx +++ b/Server/frontend/components/Sidebar.jsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; import Link from "next/link"; import { logo, sun } from '../assets'; -import { navlinks } from '../constants'; +import { navlinks } from '../pages/api/proposals/constants'; import styles from '../styles/Header.module.css'; const Icon = ({ styles, name, imgUrl, isActive, disabled, handleClick }) => ( diff --git a/Server/frontend/constants/index.ts b/Server/frontend/pages/api/proposals/constants/index.ts similarity index 94% rename from Server/frontend/constants/index.ts rename to Server/frontend/pages/api/proposals/constants/index.ts index 555e82a3..112c2e12 100644 --- a/Server/frontend/constants/index.ts +++ b/Server/frontend/pages/api/proposals/constants/index.ts @@ -1,4 +1,4 @@ -import { createCampaign, dashboard, logout, payment, profile, withdraw } from '../assets'; +import { createCampaign, dashboard, logout, payment, profile, withdraw } from '../../../../assets'; export const navlinks = [ { diff --git a/Server/frontend/context/index.jsx b/Server/frontend/pages/api/proposals/context/index.jsx similarity index 100% rename from Server/frontend/context/index.jsx rename to Server/frontend/pages/api/proposals/context/index.jsx diff --git a/Server/frontend/pages/api/proposals/fetchProposals.js b/Server/frontend/pages/api/proposals/fetchProposals.js index 35f4b898..e38a5c39 100644 --- a/Server/frontend/pages/api/proposals/fetchProposals.js +++ b/Server/frontend/pages/api/proposals/fetchProposals.js @@ -1,6 +1,23 @@ /*import { useContract, useContractRead } from "@thirdweb-dev/react"; export default function fetchProposalFromContract () { + /* + const [isLoading, setIsLoading] = useState(false); + const [proposals, setProposals] = useState([]); + + const { address, contract, getProposals } = useStateContext(); + const fetchProposals = async () => { // This is to allow us to call this g.request in the useEffect (as the request is async in /context) + setIsLoading(true); + const data = await getProposals(); + setProposals(data); + setIsLoading(false); + } + + useEffect(() => { + if (contract) fetchProposals(); + }, [address, contract]); // Re-called when these change + */ + /*const { contract, isLoading, error } = useContract("0xCcaA1ABA77Bae6296D386C2F130c46FEc3E5A004"); const proposalData = contract.call("numberOfClassifications") const allProposals = fetch('/proposals');