From 92e4b6db4763a62004a61602e864fc6e10acb760 Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Fri, 10 Jun 2022 18:03:37 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=88=F0=9F=90=A9=20->=20Confirmed=20tha?= =?UTF-8?q?t=20traditional=20english=20spelling=20was=20part=20of=20the=20?= =?UTF-8?q?cause=20of=20#32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- package.json | 5 +- src/pages/Backup.js | 157 ---------- src/pages/Home.js | 140 ++++++++- src/sampleProposals.js | 29 -- yarn.lock | 654 +++++++++++++++++++++++++++++++++++++---- 6 files changed, 730 insertions(+), 257 deletions(-) delete mode 100644 src/pages/Backup.js delete mode 100644 src/sampleProposals.js diff --git a/.env b/.env index 1283436c..07d00ee1 100644 --- a/.env +++ b/.env @@ -5,7 +5,7 @@ REACT_APP_MORALIS_SERVER_URL = https://pqrdt3y1tim2.usemoralis.com:2053/server # Polygon scan API Key API_KEY = 'QQWZ6TKJZVXCBDVHUYG5PMZH2EDZ2PN455' # Moralis Mumbai Endpoint -POLYGON_MUMBAI = 'https://speedy-nodes-nyc.moralis.io/b1a31628318e3734d3041852/polygon/mumbai' +POLYGON_MUMBAI = https://speedy-nodes-nyc.moralis.io/b1a31628318e3734d3041852/polygon/mumbai # Wallet Private key PRIVATE_KEY = '9ef07433abd17eb5479438636d216f16d0c8b3044070f2f28897710622f85bbb' diff --git a/package.json b/package.json index 0e295dd2..dd5c143b 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,12 @@ "@testing-library/jest-dom": "^5.16.2", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", + "@thirdweb-dev/react": "^2.4.1", + "@thirdweb-dev/sdk": "^2.2.11", "antd": "^4.18.7", "assert": "^2.0.0", "crypto-browserify": "^3.12.0", + "ethers": "^5.6.6", "https-browserify": "^1.0.0", "moralis": "^1.3.2", "os-browserify": "^0.3.0", @@ -49,4 +52,4 @@ "devDependencies": { "hardhat": "^2.9.3" } -} \ No newline at end of file +} diff --git a/src/pages/Backup.js b/src/pages/Backup.js deleted file mode 100644 index 94c7b72a..00000000 --- a/src/pages/Backup.js +++ /dev/null @@ -1,157 +0,0 @@ -import React, { useEffect, useState } from "react"; -import "./pages.css"; -import { TabList, Tab, Widget, Tag, Table, Form } from "web3uikit"; -import { Link } from 'react-router-dom'; -import { useMoralis } from "react-moralis"; - -const Home = () => { - const [passRate, setPassRate] = useState(0); - const [totalP, setTotalP] = useState(0); - const [counted, setCounted] = useState(0); - const { Moralis, isInitialised } = useMoralis(); - const [proposals, setProposals] = useState(); - - async function getStatus(proposalId) { - const ProposalCounts = Moralis.Object.extend("ProposalCounts"); // query the "ProposalCounts" table on Moralis and assign its values to a temporary variable - const query = new Moralis.Query(ProposalCounts); - // Search through the proposals to find the desired one (when passed as a param in /proposal.js) - query.equalTo("uid", proposalId); - const result = await query.first(); // since the id is a unique identifier, ONLY select the first match found - if (result !== undefined) { - if (result.attributes.passed) { // For a finished/expired proposal: configure the UI/visuals based on its votes/pass status - return { color: "green", text: "Passed" }; - } else { - return { color: "red", text: "Rejected" }; - } - } else { // If undefined, then there is no passed attribute for the item, so it is an ongoing proposal and should be displayed with visuals identifying this on frontend - return { color: "blue", text: "Ongoing" }; - } - } - - // Update this whenever Moralis is initialised/when ifInitailized is updated/changed. This allows us to retrieve new proposals that have been added to the DB - useEffect(() => { - if (isInitialised) { - async function getProposals() { - const Proposals = Moralis.Object.extend("Proposals"); - const query = new Moralis.Query(Proposals); - query.descending("uid_decimal"); - const results = await query.find(); - const table = await Promise.all( - results.map(async (e) => [ - e.attributes.uid, - e.attributes.description, - - - , - ]) - ); - //setProposals(table); - //setTotalP(results.length); // The number of proposals (totalP) is just how many results are returned in the table - } - - /*async function getPassRate() { - const ProposalCounts = Moralis.Object.extend("ProposalCounts"); - const query = new Moralis.Query(ProposalCounts); - const results = await query.find(); - let votesUp = 0; - - results.forEach((e) => { - if (e.attributes.passed) { - votesUp++; - } - }); - - setCounted(results.length); - setPassRate((votesUp / results.length) * 100); - }*/ - - //getProposals(); - //getPassRate(); - } - }, [isInitialised]); - - return ( - <> -
- - {/* Make sure that proposals are defined before rendering the rest of the DAO */} - -
- Governance Overview -
- -
-
Pass Rate
-
-
-
-
-
- - -
- Recent Proposals -
- ID, - Description, - Status, - ]} - pageSize={5} - /> - - { - alert("Proposal Submitted") - }} - title="Create a new Proposal" - /> - - - - {/* Minimal/lightweight alternatives to something like Flarum -> Create extra tabs in proposals for comments, link to Discord*/} - - - -
- - ); -}; - -export default Home; \ No newline at end of file diff --git a/src/pages/Home.js b/src/pages/Home.js index becc32ee..f160a418 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -2,22 +2,24 @@ import React, { useEffect, useState } from "react"; import "./pages.css"; import './content.css' import { TabList, Tab, Widget, Tag, Table, Form } from "web3uikit"; -import { Link } from 'react-router-dom'; -import { useMoralis } from "react-moralis"; - +import { Link } from "react-router-dom"; +import { useMoralis, useMoralisWeb3Api, useWeb3ExecuteFunction } from "react-moralis"; +// import { useAddress, useMetamask, useEditionDrop } from '@thirdweb-dev/react'; const Home = () => { + //const address = useAddress(); + //const connectWithMetamask = useMetamask(); + const [passRate, setPassRate] = useState(0); const [totalP, setTotalP] = useState(0); const [counted, setCounted] = useState(0); - const { Moralis, isInitialised } = useMoralis(); - const [proposals, setProposals] = useState([]); + const {Moralis, isInitialized} = useMoralis(); + const [proposals, setProposals] = useState(); async function getStatus(proposalId) { - const ProposalCounts = Moralis.Object.extend("ProposalCounts"); // query the "ProposalCounts" table on Moralis and assign its values to a temporary variable + const ProposalCounts = Moralis.Object.extend("ProposalCounts"); // query the "ProposalCounts" table on Moralis and assign its values to a temporary variable const query = new Moralis.Query(ProposalCounts); - // Search through the proposals to find the desired one (when passed as a param in /proposal.js) - query.equalTo("uid", proposalId); + query.equalTo("uid", proposalId); // Search through the proposals to find the desired one (when passed as a param in /proposal.js) const result = await query.first(); // since the id is a unique identifier, ONLY select the first match found if (result !== undefined) { if (result.attributes.passed) { // For a finished/expired proposal: configure the UI/visuals based on its votes/pass status @@ -32,21 +34,68 @@ const Home = () => { // Update this whenever Moralis is initialised/when ifInitailized is updated/changed. This allows us to retrieve new proposals that have been added to the DB useEffect(() => { - if (isInitialised) { + if (isInitialized) { + async function getProposals() { // Find proposals from the Moralis db + const Proposals = Moralis.Object.extend("Proposals"); + const query = new Moralis.Query(Proposals); + query.descending("uid_decimal"); // Order the proposals in the variable with the latest/most recent appearing first + const results = await query.find(); + + // Frontend table displaying proposals + const table = await Promise.all( + results.map(async (e) => [ + e.attributes.uid, + e.attributes.description, + + + , + ]) + ); + setProposals(table); // Updated each time Moralis db is fetched + setTotalP(results.length); // Number of total proposals (not just ongoing ones) + } + + // Function to determine the pass rate of proposals for widget on home screen + async function getPassRate() { + const ProposalCounts = Moralis.Object.extend("ProposalCounts"); + const query = new Moralis.Query(ProposalCounts); + const results = await query.find(); + let votesUp = 0; + results.forEach((e) => { + if (e.attributes.passed) { + votesUp++; + } + }); + setCounted(results.length); + setPassRate((votesUp / results.length) * 100); + } + getProposals(); + getPassRate(); } - }, [isInitialised]); + }, [isInitialized]); + return ( <>
+ {proposals && ( /* Only render the Proposals table if the proposals state variable is available and working */
Governance Overview
@@ -55,13 +104,13 @@ const Home = () => {
- +
Recent Proposals
@@ -100,13 +149,72 @@ const Home = () => { title="Create a new Proposal" />
+ )}
{/* Minimal/lightweight alternatives to something like Flarum */} - + {/* IonPhaser? */}
Documentation
-

DAO

{/* Let's add an internal DAO section using thirdweb for dev team members. Right now I'm starting to add components from the frontend of signal-k/theclub (on github) */} +

DAO

{/* Let's add an internal DAO section using thirdweb for dev team members. Right now I'm starting to add components from the frontend of signal-k/theclub (on github) + Try and add the Contract view table from the old DAO: /~https://github.com/Gizmotronn/mint/blob/main/src/editionDrop.js + https://mumbai.polygonscan.com/address/0x418805aed44e7105eeec35289fe4d60acfa733af#writeContract + */} +



+
+ + +
+