From bbb5593992ca83970021c0cd58724f583ed16b34 Mon Sep 17 00:00:00 2001 From: David Llop <931684+sembrestels@users.noreply.github.com> Date: Wed, 9 Sep 2020 00:12:35 +0200 Subject: [PATCH] Commons Stack + Panvala CV Pilot --- src/assets/logo-cs.svg | 54 +++++ src/components/AddProposalPanel.js | 300 +++----------------------- src/components/ConvictionBanner.js | 7 +- src/components/FilterBar/FilterBar.js | 34 +-- src/components/Footer.js | 42 ++-- src/components/Header.js | 6 +- src/components/Metrics.js | 72 ++----- src/networks.js | 11 +- src/screens/ProposalDetail.js | 3 +- 9 files changed, 142 insertions(+), 387 deletions(-) create mode 100644 src/assets/logo-cs.svg diff --git a/src/assets/logo-cs.svg b/src/assets/logo-cs.svg new file mode 100644 index 0000000..cf56f9a --- /dev/null +++ b/src/assets/logo-cs.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/AddProposalPanel.js b/src/components/AddProposalPanel.js index e1cd2df..29293cb 100644 --- a/src/components/AddProposalPanel.js +++ b/src/components/AddProposalPanel.js @@ -1,129 +1,24 @@ import React, { useCallback, useMemo, useState } from 'react' -import { - Button, - Checkbox, - DropDown, - Field, - GU, - Info, - Link, - isAddress, - TextInput, - useTheme, -} from '@aragon/ui' +import { Button, TextInput, Info, Field, GU, Link } from '@aragon/ui' import { useAppState } from '../providers/AppState' -import BigNumber from '../lib/bigNumber' -import { toDecimals } from '../lib/math-utils' -import { formatTokenAmount } from '../lib/token-utils' -import { calculateThreshold, getMaxConviction } from '../lib/conviction' - import { ZERO_ADDR } from '../constants' -const NULL_PROPOSAL_TYPE = -1 -const FUNDING_PROPOSAL = 1 - -const BASE_IPFS_URI = 'https://ipfs.eth.aragon.network/ipfs/' -const TC_IPFS_HASH = 'QmTSDxWVFnNUis8ZJ7aBfH2z71Jc4N62YLYM9PzJz8DUjt' - const DEFAULT_FORM_DATA = { title: '', link: '', - proposalType: NULL_PROPOSAL_TYPE, - amount: { - value: '0', - valueBN: new BigNumber(0), - }, - beneficiary: '', } const AddProposalPanel = React.memo(({ onSubmit }) => { - const [termsAccepted, setTermsAccepted] = useState(false) - const theme = useTheme() - const { - alpha, - maxRatio, - requestToken, - stakeToken, - totalSupply, - vaultBalance, - weight, - } = useAppState() + const { accountBalance } = useAppState() const [formData, setFormData] = useState(DEFAULT_FORM_DATA) - const fundingMode = formData.proposalType === FUNDING_PROPOSAL - - const handleAmountEditMode = useCallback( - editMode => { - setFormData(formData => { - const { amount } = formData - - const newValue = amount.valueBN.gte(0) - ? formatTokenAmount( - amount.valueBN, - stakeToken.decimals, - false, - false, - { - commas: !editMode, - replaceZeroBy: editMode ? '' : '0', - rounding: stakeToken.decimals, - } - ) - : '' - - return { - ...formData, - amount: { - ...amount, - value: newValue, - }, - } - }) - }, - [stakeToken] - ) - - const handleProposalTypeChange = useCallback(selected => { - setFormData(formData => ({ - ...formData, - proposalType: selected, - })) - }, []) - const handleTitleChange = useCallback(event => { const updatedTitle = event.target.value setFormData(formData => ({ ...formData, title: updatedTitle })) }, []) - const handleAmountChange = useCallback( - event => { - const updatedAmount = event.target.value - - const newAmountBN = new BigNumber( - isNaN(updatedAmount) - ? -1 - : toDecimals(updatedAmount, stakeToken.decimals) - ) - - setFormData(formData => ({ - ...formData, - amount: { - value: updatedAmount, - valueBN: newAmountBN, - }, - })) - }, - [stakeToken.decimals] - ) - - const handleBeneficiaryChange = useCallback(event => { - const updatedBeneficiary = event.target.value - - setFormData(formData => ({ ...formData, beneficiary: updatedBeneficiary })) - }, []) - const handleLinkChange = useCallback(event => { const updatedLink = event.target.value setFormData(formData => ({ ...formData, link: updatedLink })) @@ -133,82 +28,43 @@ const AddProposalPanel = React.memo(({ onSubmit }) => { event => { event.preventDefault() - const { amount, beneficiary = ZERO_ADDR, link, title } = formData - const convertedAmount = amount.valueBN.toFixed(0) + const { link, title } = formData onSubmit({ title, link, - amount: convertedAmount, - beneficiary: beneficiary || ZERO_ADDR, + amount: 0, + beneficiary: ZERO_ADDR, }) }, [formData, onSubmit] ) const errors = useMemo(() => { - const errors = [] - - const { amount, beneficiary, title } = formData - if (requestToken) { - if (amount.valueBN.eq(-1)) { - errors.push('Invalid requested amount') - } - - if (beneficiary && !isAddress(beneficiary)) { - errors.push('Beneficiary is not a valid ethereum address') - } - - return errors - } + const { title } = formData return !title - }, [formData, requestToken]) - - const neededThreshold = useMemo(() => { - const threshold = calculateThreshold( - formData.amount.valueBN, - vaultBalance, - totalSupply, - alpha, - maxRatio, - weight - ) + }, [formData]) - const max = getMaxConviction(totalSupply, alpha) - return Math.round((threshold / max) * 100) - }, [alpha, formData.amount, maxRatio, totalSupply, vaultBalance, weight]) + const submitDisabled = !formData.title || !formData.link - const submitDisabled = - formData.proposalType === NULL_PROPOSAL_TYPE || - (formData.proposalType === FUNDING_PROPOSAL && - (formData.amount.value === '0' || !formData.beneficiary)) || - !formData.title || - !termsAccepted + if (accountBalance.toString() === '0') { + return ( + + You must have CSTK tokens to propose a grant. Switch to the address that + holds your CSTK Tokens or{' '} + + Apply to join the Trusted Seed + + . + + ) + } return (
- - - - Remember to{' '} - - add your proposal to the forum - {' '} - first, and then add the link here. + Please use the Gitcoin Grant title as the title for your proposal and + include the link to the Grant down below. { required /> - {requestToken && fundingMode && ( - <> - handleAmountEditMode(true)} - onBlur={() => handleAmountEditMode(false)} - > - - {requestToken.symbol} - - } - adornmentPosition="end" - adornmentSettings={{ padding: 1 }} - /> - - - - - - )} - + - - {formData.proposalType !== NULL_PROPOSAL_TYPE && ( - - {fundingMode ? ( - <> - - This action will create a proposal which can be voted on - {' '} - - by staking {stakeToken.symbol}. - {' '} - - The action will be executable if the accrued total stake reaches - above the threshold. - - - ) : ( - <> - - This action will create a proposal which can be voted on, - {' '} - - it's a proposal without a requested amount. - {' '} - The action will not be executable. - - )} - - )} - {fundingMode && formData.amount.valueBN.gte(0) && ( - - {neededThreshold - ? `Required conviction for requested amount in order for the proposal to - pass is ~%${neededThreshold}` - : `Proposal might never pass with requested amount`} - - )} {errors.length > 0 && ( - We just released the Conviction funding pilot! Learn about how to - participate! + Choose which Gitcoin Grants will receive extra matching via Panvala! - Discover + Learn more

- - - {!statusFilterDisabled && ( - - )}
- Community + Commons Stack - - Blog + + Home - - Github + + Components - - Twitter + + Community - - Forum + + Apply
@@ -71,13 +71,25 @@ export default function Footer({ compact }) { margin-bottom: ${1.5 * GU}px; `} > - Tools + Join Us - - Wiki + + Twitter - - Connect + + Medium + + + Telegram + + + Riot Chat + + + Github
diff --git a/src/components/Header.js b/src/components/Header.js index cd7fa5b..89a7eef 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,7 +1,7 @@ import React, { useCallback } from 'react' import { textStyle, GU } from '@aragon/ui' import { useAppState } from '../providers/AppState' -import logoAaSvg from '../assets/logo-aa.svg' +import logoCSSvg from '../assets/logo-cs.svg' function Header() { const { appearance, setAppearance } = useAppState() @@ -28,7 +28,7 @@ function Header() { `} > - Aragon Association + Commons Stack diff --git a/src/components/Metrics.js b/src/components/Metrics.js index 6de7d28..7655f8f 100644 --- a/src/components/Metrics.js +++ b/src/components/Metrics.js @@ -12,7 +12,6 @@ import { } from '@aragon/ui' import AccountModule from './Account/AccountModule' import Carousel from './Carousel/Carousel' -import { useUniswapAntPrice } from '../hooks/useUniswapAntPrice' import BigNumber from '../lib/bigNumber' import { formatTokenAmount } from '../lib/token-utils' import { useAppState } from '../providers/AppState' @@ -33,7 +32,6 @@ const Metrics = React.memo(function Metrics({ const { layoutName } = useLayout() const theme = useTheme() const compactMode = layoutName === 'small' - const uniAntPrice = useUniswapAntPrice() const myActiveTokens = useMemo(() => { if (!myStakes) { @@ -53,9 +51,13 @@ const Metrics = React.memo(function Metrics({ const carouselContent = useMemo( () => [ - , - , - , + , + , + , ], [accountBalance, myActiveTokens, inactiveTokens] ) @@ -130,14 +132,19 @@ const Metrics = React.memo(function Metrics({ What is voting influence? - We captured a snapshot of your ANT balance on 2020/08/26 - that has been translated into your current voting influence.{' '} + You can get{' '} - Learn more + CSTK tokens + {' '} + for contributing to the Commons Stack mission and receiving + praise or by{' '} + + donating to support us + . @@ -169,26 +176,6 @@ const Metrics = React.memo(function Metrics({ )} )} - -
-
@@ -198,7 +185,7 @@ const Metrics = React.memo(function Metrics({ label="Token Supply" value={totalSupply} token={stakeToken} - symbol="ANT" + symbol="CSTK" /> @@ -206,7 +193,7 @@ const Metrics = React.memo(function Metrics({ label="Active" value={totalActiveTokens} token={stakeToken} - symbol="ANT" + symbol="CSTK" /> @@ -301,21 +288,6 @@ function CarouselBalance({ amount, decimals = 18, label, symbol = 'ANT' }) { } function TokenBalance({ label, token, value, symbol, uppercased }) { - const theme = useTheme() - const uniAntPrice = useUniswapAntPrice() - - const valueFormatted = formatTokenAmount( - value.toFixed(0), - token.decimals, - undefined, - false, - { - commas: false, - } - ).replace(/,/g, '') - - const antFinalPrice = Number(uniAntPrice) * Number(valueFormatted) - return ( <> -
- {`$ ${antFinalPrice.toLocaleString()}`} -
) } diff --git a/src/networks.js b/src/networks.js index 53b4175..11bc4f5 100644 --- a/src/networks.js +++ b/src/networks.js @@ -5,11 +5,10 @@ const networks = { mainnet: { chainId: 1, ensRegistry: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', - defaultEthNode: 'wss://mainnet.eth.aragon.network/ws', + defaultEthNode: + 'wss://mainnet.infura.io/ws/v3/fb8cf9d97ab44df7b4a268b282c04803', defaultSubgraphUrl: - 'https://graph.backend.aragon.org/subgraphs/name/1hive/aragon-conviction-voting-mainnet', - generalSubgraphUrl: - 'https://graph.backend.aragon.org/subgraphs/name/aragon/aragon-mainnet', + 'https://api.thegraph.com/subgraphs/name/1hive/aragon-conviction-voting-mainnet', name: 'Mainnet', orgAddress: '0xaAf56C0D604dDB88bBe451ae0db4580Ca3D49c0A', type: 'mainnet', @@ -28,8 +27,10 @@ const networks = { chainId: 100, ensRegistry: '0xaafca6b0c89521752e559650206d7c925fd0e530', defaultEthNode: 'https://xdai.poanetwork.dev/', + defaultSubgraphUrl: + 'https://api.thegraph.com/subgraphs/name/1hive/aragon-c-v-beta-xdai', name: 'xDai', - orgAddress: '', + orgAddress: '0x1cDC45012c4A20FF96a273e83B9C4173948F8b4d', type: 'xdai', }, } diff --git a/src/screens/ProposalDetail.js b/src/screens/ProposalDetail.js index 659ecb8..8fbbe26 100644 --- a/src/screens/ProposalDetail.js +++ b/src/screens/ProposalDetail.js @@ -242,7 +242,8 @@ function ProposalDetail({ > {beneficiary === ZERO_ADDR && }{' '} {status !== 'Cancelled' ? ( - requestToken && ( + requestToken && + !signalingProposal && (