Skip to content

Commit

Permalink
💈🐩 -> Confirmed that traditional english spelling was part of the cau…
Browse files Browse the repository at this point in the history
…se of #32
  • Loading branch information
Gizmotronn authored Jun 10, 2022
1 parent 31d6032 commit 92e4b6d
Show file tree
Hide file tree
Showing 6 changed files with 730 additions and 257 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -49,4 +52,4 @@
"devDependencies": {
"hardhat": "^2.9.3"
}
}
}
157 changes: 0 additions & 157 deletions src/pages/Backup.js

This file was deleted.

140 changes: 124 additions & 16 deletions src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
<Link to="/proposal" state={{
description: e.attributes.description,
color: (await getStatus(e.attributes.uid)).color,
text: (await getStatus(e.attributes.uid)).text,
id: e.attributes.uid,
proposer: e.attributes.proposer
}}>
<Tag // Tag showing the status of a proposal, wrapped around the link to the proposal page (state)
color={(await getStatus(e.attributes.uid)).color}
text={(await getStatus(e.attributes.uid)).text}
/>
</Link>,
])
);
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 (
<>
<div className="content">
<TabList defaultActiveKey={1} tabStyle="bulbUnion">
<Tab tabKey={1} tabName="DAO">
{proposals && ( /* Only render the Proposals table if the proposals state variable is available and working */
<div className="tabContent">
Governance Overview
<div className="widgets">
<Widget
info={52}
info={totalP}
title="Proposals Created"
style={{ width: "200%" }}
>
Expand All @@ -55,13 +104,13 @@ const Home = () => {
<div className="progress">
<div
className="progressPercentage"
style={{ width: `${60}%` }}
style={{ width: `${passRate}%` }}
></div>
</div>
</div>
</Widget>
<Widget info={423} title="Eligible Voters" />
<Widget info={5} title="Ongoing Proposals" />
<Widget info={totalP-counted} title="Ongoing Proposals" />
</div>
Recent Proposals
<div style={{ marginTop: "30px" }}>
Expand Down Expand Up @@ -100,13 +149,72 @@ const Home = () => {
title="Create a new Proposal"
/>
</div>
)}
</Tab>
<Tab tabKey={2} tabName="Forum"></Tab> {/* Minimal/lightweight alternatives to something like Flarum */}
<Tab tabKey={3} tabName="Docs">
<Tab tabKey={3} tabName="Docs"> {/* IonPhaser? */}
<div className="tabContent">
Documentation
<div className="landing">
<h1>DAO</h1> {/* 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) */}
<h1>DAO</h1> {/* 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
*/}
<br></br><br></br>
<div className="content">
<TabList defaultActiveKey={1} tabStyle="bulbUnion">
<Tab tabKey={1} tabName="Super">
<div className="tabContent">
<iframe src="https://sk.super.site" height="600px" width="100%"/>;
</div>
</Tab>
<Tab tabKey={2} tabName="Forum">
<div className="tabContent">
Contract status
<div style={{ marginTop: "30px" }}>
<Table
columnsConfig="10% 70% 20%"
data={[
[
1,
<div>Should we start a Moralis hamburger chain?</div>,
<Tag color="green" text="Passed" />,
],
[
2,
"Should we accept Elon Musks $44billion offer for our DAO?",
<Link to="/proposal" state={"hello"}>
<Tag color="red" text="Rejected" />
</Link>,
],
[
3,
"Do you want a Web3 Slack tutorial?",
<Tag color="blue" text="Ongoing" />,
],
[
4,
"Are you interested in Xbox/Console web3 tutorials?",
<Tag color="blue" text="Ongoing" />,
],
[
5,
"Would you attend a Moralis Builder get together in Miami?",
<Tag color="blue" text="Ongoing" />,
],
]}
header={[
<span>ID</span>,
<span>Description</span>,
<span>Status</span>,
]}
pageSize={5}
/>
</div>
</div>
</Tab>
</TabList>
</div>
</div>
</div>
</Tab>
Expand All @@ -117,4 +225,4 @@ const Home = () => {
);
};

export default Home;
export default Home;
Loading

0 comments on commit 92e4b6d

Please sign in to comment.