diff --git a/packages/react-app/src/App.jsx b/packages/react-app/src/App.jsx index d14cceac..1720d576 100644 --- a/packages/react-app/src/App.jsx +++ b/packages/react-app/src/App.jsx @@ -5,7 +5,7 @@ import WalletLink from "walletlink"; import { Alert, Button } from "antd"; import "antd/dist/antd.css"; import React, { useCallback, useEffect, useState } from "react"; -import { BrowserRouter, Route, Switch } from "react-router-dom"; +import { BrowserRouter, Route, Switch, useHistory } from "react-router-dom"; import Web3Modal from "web3modal"; import "./App.css"; import { Account, Contract, Header, Footer } from "./components"; @@ -21,7 +21,7 @@ import Portis from "@portis/web3"; import Fortmatic from "fortmatic"; import Authereum from "authereum"; -import { Box } from "@chakra-ui/react"; +import { Box, HStack, Flex, Spacer } from "@chakra-ui/react"; import NotConnectedCard from "./components/Cards/NotConnectedCard"; import CenteredFrame from "./components/layout/CenteredFrame"; @@ -115,8 +115,7 @@ const web3Modal = new Web3Modal({ // }, "custom-walletlink": { display: { - logo: - "https://play-lh.googleusercontent.com/PjoJoG27miSglVBXoXrxBSLveV6e3EeBPpNY55aiUUBM9Q1RCETKCOqdOkX2ZydqVf0", + logo: "https://play-lh.googleusercontent.com/PjoJoG27miSglVBXoXrxBSLveV6e3EeBPpNY55aiUUBM9Q1RCETKCOqdOkX2ZydqVf0", name: "Coinbase", description: "Connect to Coinbase Wallet (not Coinbase App)", }, @@ -409,23 +408,30 @@ function App(props) { }, [yourLocalBalance]); return ( -
- {networkDisplay} - -
- -
-
+
+ + + + +
+ + + + + + + + {address && address !== "" ? ( diff --git a/packages/react-app/src/components/Account.jsx b/packages/react-app/src/components/Account.jsx index 5bed00e7..f63e8089 100644 --- a/packages/react-app/src/components/Account.jsx +++ b/packages/react-app/src/components/Account.jsx @@ -1,44 +1,7 @@ -import { Button } from "antd"; import React from "react"; import { useThemeSwitcher } from "react-css-theme-switcher"; -import Address from "./Address"; -import Balance from "./Balance"; -import Wallet from "./Wallet"; -import { Text, Heading, VStack, HStack, Divider as ChDivider, Button as ChButton, Avatar } from "@chakra-ui/react"; - -/* - ~ What it does? ~ - - Displays an Address, Balance, and Wallet as one Account component, - also allows users to log in to existing accounts and log out - - ~ How can I use? ~ - - - - ~ Features ~ - - - Provide address={address} and get balance corresponding to the given address - - Provide localProvider={localProvider} to access balance on local network - - Provide userProvider={userProvider} to display a wallet - - Provide mainnetProvider={mainnetProvider} and your address will be replaced by ENS name - (ex. "0xa870" => "user.eth") - - Provide price={price} of ether and get your balance converted to dollars - - Provide web3Modal={web3Modal}, loadWeb3Modal={loadWeb3Modal}, logoutOfWeb3Modal={logoutOfWeb3Modal} - to be able to log in/log out to/from existing accounts - - Provide blockExplorer={blockExplorer}, click on address and get the link - (ex. by default "https://etherscan.io/" or for xdai "https://blockscout.com/poa/xdai/") -*/ +import { Box, Button } from "@chakra-ui/react"; +import { useLookupAddress } from "eth-hooks/dapps/ens"; export default function Account({ address, @@ -52,30 +15,32 @@ export default function Account({ logoutOfWeb3Modal, blockExplorer, }) { + const lookup = useLookupAddress(mainnetProvider, address); + const ensSplit = lookup?.split("."); + const validEnsCheck = ensSplit && ensSplit[ensSplit.length - 1] === "eth"; + + let displayAddress = "Loading..."; + + if (validEnsCheck) { + displayAddress = lookup; + } else { + displayAddress = + address !== undefined + ? `${address.substr(0, 5)}...${address.substr(address.length - 6, address.length)}` + : "Loading..."; + } + const modalButtons = []; if (web3Modal) { if (web3Modal.cachedProvider) { modalButtons.push( - , ); } else { modalButtons.push( - , ); @@ -84,31 +49,5 @@ export default function Account({ const { currentTheme } = useThemeSwitcher(); - const display = minimized ? ( - "" - ) : ( - - {address ? ( -
- ) : ( - "Connecting..." - )} - {/* */} - {/* */} - - ); - - return ( - - {display} - {modalButtons} - - ); + return {modalButtons}; } diff --git a/packages/react-app/src/components/Footer.jsx b/packages/react-app/src/components/Footer.jsx index 03073ceb..90217c59 100644 --- a/packages/react-app/src/components/Footer.jsx +++ b/packages/react-app/src/components/Footer.jsx @@ -1,4 +1,4 @@ -import { Flex, HStack, Link, Text, Box, useColorModeValue } from "@chakra-ui/react"; +import { Flex, HStack, Link, Text, Box, useColorModeValue, Spacer} from "@chakra-ui/react"; import { Icon } from "@chakra-ui/icon"; import { FaGithub } from "react-icons/fa"; @@ -6,8 +6,27 @@ import GitcoinIcon from "./Icons/GitcoinIcon"; const Footer = () => { return ( - - + + + + + + + + + + Moonshot Collective + + + {/* @@ -27,7 +46,7 @@ const Footer = () => { }} /> - + */} ); }; diff --git a/packages/react-app/src/components/Header.jsx b/packages/react-app/src/components/Header.jsx index 7350c1e2..a756f3cb 100644 --- a/packages/react-app/src/components/Header.jsx +++ b/packages/react-app/src/components/Header.jsx @@ -7,19 +7,12 @@ import QDIcon from "./Icons/QDIcon"; export default function Header() { const headingColor = useColorModeValue("yellow.600", "yellow.500"); return ( - - - - - - - pay.party - - - - by MOONSHOT COLLECTIVE - - + + + + + pay.party + ); diff --git a/packages/react-app/src/routes/create/Create.jsx b/packages/react-app/src/routes/create/Create.jsx index 154ec644..7ad71280 100644 --- a/packages/react-app/src/routes/create/Create.jsx +++ b/packages/react-app/src/routes/create/Create.jsx @@ -1,12 +1,5 @@ -import { - Box, - Button, - FormControl, - FormLabel, - Input, - Textarea, - Select, -} from "@chakra-ui/react"; +import { Box, Button, FormControl, FormLabel, Input, Textarea, Select } from "@chakra-ui/react"; +import { ArrowBackIcon } from "@chakra-ui/icons"; import React, { useState } from "react"; import { useHistory } from "react-router-dom"; import MongoDBController from "../../controllers/mongodbController"; @@ -18,14 +11,13 @@ const Create = ({ address, mainnetProvider, userSigner, tx, readContracts, write const db = new MongoDBController(); const [loading, setLoading] = useState(false); - const [partyObj, setPartyObj] = useState({ name: "", description: "", - receipts: [], + receipts: [], config: { - strategy: "", - nvotes: 0 + strategy: "", + nvotes: 0, }, participants: [], candidates: [], @@ -35,71 +27,76 @@ const Create = ({ address, mainnetProvider, userSigner, tx, readContracts, write const onSubmit = async event => { event.preventDefault(); setLoading(true); - db.newParty(partyObj) - .then(d => { - setLoading(false); - }) - .catch(err => { - console.log(err); - }); + userSigner.signMessage(`Create party:\n${partyObj.name}`).then(sig => { + // TODO: Do something with this + db.newParty(partyObj) + .then(d => { + setLoading(false); + }) + .catch(err => { + console.log(err); + }); + }); }; return ( - + -
- - Name - (partyObj.name = e.currentTarget.value)} /> + + + + Name + (partyObj.name = e.currentTarget.value)} /> - Desciption - + Participants + + Candidates +