Commit 9c473270 authored by Ian Lapham's avatar Ian Lapham Committed by GitHub

fix(governance): modal bugs, redable styles, show common names for contracts (#1164)

* fix modal bugs, reable styles, show common names for contracts

* use theme for blue
parent b650b175
...@@ -34,6 +34,12 @@ export const UNI: { [chainId in ChainId]: Token } = { ...@@ -34,6 +34,12 @@ export const UNI: { [chainId in ChainId]: Token } = {
[ChainId.KOVAN]: new Token(ChainId.KOVAN, UNI_ADDRESS, 18, 'UNI', 'Uniswap') [ChainId.KOVAN]: new Token(ChainId.KOVAN, UNI_ADDRESS, 18, 'UNI', 'Uniswap')
} }
export const COMMON_CONTRACT_NAMES: { [address: string]: string } = {
'0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984': 'UNI',
'0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F': 'Governance Alpha',
'0x1a9C8182C09F50C8318d769245beA52c32BE35BC': 'Timelock'
}
// TODO: specify merkle distributor for mainnet // TODO: specify merkle distributor for mainnet
export const MERKLE_DISTRIBUTOR_ADDRESS: { [chainId in ChainId]?: string } = { export const MERKLE_DISTRIBUTOR_ADDRESS: { [chainId in ChainId]?: string } = {
[ChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e' [ChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e'
......
...@@ -17,8 +17,11 @@ import VoteModal from '../../components/vote/VoteModal' ...@@ -17,8 +17,11 @@ import VoteModal from '../../components/vote/VoteModal'
import { TokenAmount, JSBI } from '@uniswap/sdk' import { TokenAmount, JSBI } from '@uniswap/sdk'
import { useTokenBalance } from '../../state/wallet/hooks' import { useTokenBalance } from '../../state/wallet/hooks'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { UNI, ZERO_ADDRESS, PROPOSAL_LENGTH_IN_DAYS } from '../../constants' import { UNI, ZERO_ADDRESS, PROPOSAL_LENGTH_IN_DAYS, COMMON_CONTRACT_NAMES } from '../../constants'
import { isAddress, getEtherscanLink } from '../../utils' import { isAddress, getEtherscanLink } from '../../utils'
import { ApplicationModal } from '../../state/application/actions'
import { useModalOpen, useToggleDelegateModal, useToggleVoteModal } from '../../state/application/hooks'
import DelegateModal from '../../components/vote/DelegateModal'
const PageWrapper = styled(AutoColumn)` const PageWrapper = styled(AutoColumn)`
width: 100%; width: 100%;
...@@ -108,7 +111,12 @@ export default function VotePage({ ...@@ -108,7 +111,12 @@ export default function VotePage({
const [support, setSupport] = useState<boolean>(true) const [support, setSupport] = useState<boolean>(true)
// modal for casting votes // modal for casting votes
const [showModal, setShowModal] = useState<boolean>(false) const showVoteModal = useModalOpen(ApplicationModal.VOTE)
const toggleVoteModal = useToggleVoteModal()
// toggle for showing delegation modal
const showDelegateModal = useModalOpen(ApplicationModal.DELEGATE)
const toggelDelegateModal = useToggleDelegateModal()
// get and format date from data // get and format date from data
const startTimestamp: number | undefined = useTimestampFromBlock(proposalData?.startBlock) const startTimestamp: number | undefined = useTimestampFromBlock(proposalData?.startBlock)
...@@ -133,21 +141,19 @@ export default function VotePage({ ...@@ -133,21 +141,19 @@ export default function VotePage({
) )
// show links in propsoal details if content is an address // show links in propsoal details if content is an address
// if content is contract with common name, replace address with common name
const linkIfAddress = (content: string) => { const linkIfAddress = (content: string) => {
if (isAddress(content) && chainId) { if (isAddress(content) && chainId) {
return <ExternalLink href={getEtherscanLink(chainId, content, 'address')}>{content}</ExternalLink> const commonName = COMMON_CONTRACT_NAMES[content] ?? content
return <ExternalLink href={getEtherscanLink(chainId, content, 'address')}>{commonName}</ExternalLink>
} }
return <span>{content}</span> return <span>{content}</span>
} }
return ( return (
<PageWrapper gap="lg" justify="center"> <PageWrapper gap="lg" justify="center">
<VoteModal <VoteModal isOpen={showVoteModal} onDismiss={toggleVoteModal} proposalId={proposalData?.id} support={support} />
isOpen={showModal} <DelegateModal isOpen={showDelegateModal} onDismiss={toggelDelegateModal} title="Unlock Votes" />
onDismiss={() => setShowModal(false)}
proposalId={proposalData?.id}
support={support}
/>
<ProposalInfo gap="lg" justify="start"> <ProposalInfo gap="lg" justify="start">
<RowBetween style={{ width: '100%' }}> <RowBetween style={{ width: '100%' }}>
<ArrowWrapper to="/vote"> <ArrowWrapper to="/vote">
...@@ -162,7 +168,7 @@ export default function VotePage({ ...@@ -162,7 +168,7 @@ export default function VotePage({
{endDate && endDate < now {endDate && endDate < now
? 'Voting ended ' + (endDate && endDate.toLocaleString(DateTime.DATETIME_FULL)) ? 'Voting ended ' + (endDate && endDate.toLocaleString(DateTime.DATETIME_FULL))
: proposalData : proposalData
? 'Voting ends approximately' + (endDate && endDate.toLocaleString(DateTime.DATETIME_FULL)) ? 'Voting ends approximately ' + (endDate && endDate.toLocaleString(DateTime.DATETIME_FULL))
: ''} : ''}
</TYPE.main> </TYPE.main>
{showUnlockVoting && endDate && endDate > now && ( {showUnlockVoting && endDate && endDate > now && (
...@@ -170,7 +176,7 @@ export default function VotePage({ ...@@ -170,7 +176,7 @@ export default function VotePage({
style={{ width: 'fit-content' }} style={{ width: 'fit-content' }}
padding="8px" padding="8px"
borderRadius="8px" borderRadius="8px"
onClick={() => setShowModal(true)} onClick={toggelDelegateModal}
> >
Unlock Voting Unlock Voting
</ButtonPrimary> </ButtonPrimary>
...@@ -188,7 +194,7 @@ export default function VotePage({ ...@@ -188,7 +194,7 @@ export default function VotePage({
borderRadius="8px" borderRadius="8px"
onClick={() => { onClick={() => {
setSupport(true) setSupport(true)
setShowModal(true) toggleVoteModal()
}} }}
> >
Vote For Vote For
...@@ -198,7 +204,7 @@ export default function VotePage({ ...@@ -198,7 +204,7 @@ export default function VotePage({
borderRadius="8px" borderRadius="8px"
onClick={() => { onClick={() => {
setSupport(false) setSupport(false)
setShowModal(true) toggleVoteModal()
}} }}
> >
Vote Against Vote Against
...@@ -260,7 +266,7 @@ export default function VotePage({ ...@@ -260,7 +266,7 @@ export default function VotePage({
})} })}
</AutoColumn> </AutoColumn>
<AutoColumn gap="md"> <AutoColumn gap="md">
<TYPE.mediumHeader fontWeight={600}>Overview</TYPE.mediumHeader> <TYPE.mediumHeader fontWeight={600}>Description</TYPE.mediumHeader>
<MarkDownWrapper> <MarkDownWrapper>
<ReactMarkdown source={proposalData?.description} /> <ReactMarkdown source={proposalData?.description} />
</MarkDownWrapper> </MarkDownWrapper>
......
import React, { useState } from 'react' import React from 'react'
import { AutoColumn } from '../../components/Column' import { AutoColumn } from '../../components/Column'
import styled from 'styled-components' import styled from 'styled-components'
import { TYPE, ExternalLink } from '../../theme' import { TYPE, ExternalLink } from '../../theme'
...@@ -19,6 +19,8 @@ import { JSBI, TokenAmount, ChainId } from '@uniswap/sdk' ...@@ -19,6 +19,8 @@ import { JSBI, TokenAmount, ChainId } from '@uniswap/sdk'
import { shortenAddress, getEtherscanLink } from '../../utils' import { shortenAddress, getEtherscanLink } from '../../utils'
import Loader from '../../components/Loader' import Loader from '../../components/Loader'
import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount' import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount'
import { useModalOpen, useToggleDelegateModal } from '../../state/application/hooks'
import { ApplicationModal } from '../../state/application/actions'
const PageWrapper = styled(AutoColumn)`` const PageWrapper = styled(AutoColumn)``
...@@ -102,7 +104,10 @@ const EmptyProposals = styled.div` ...@@ -102,7 +104,10 @@ const EmptyProposals = styled.div`
export default function Vote() { export default function Vote() {
const { account, chainId } = useActiveWeb3React() const { account, chainId } = useActiveWeb3React()
const [showModal, setShowModal] = useState<boolean>(false)
// toggle for showing delegation modal
const showDelegateModal = useModalOpen(ApplicationModal.DELEGATE)
const toggelDelegateModal = useToggleDelegateModal()
// get data to list all proposals // get data to list all proposals
const allProposals: ProposalData[] = useAllProposalData() const allProposals: ProposalData[] = useAllProposalData()
...@@ -120,8 +125,8 @@ export default function Vote() { ...@@ -120,8 +125,8 @@ export default function Vote() {
return ( return (
<PageWrapper gap="lg" justify="center"> <PageWrapper gap="lg" justify="center">
<DelegateModal <DelegateModal
isOpen={showModal} isOpen={showDelegateModal}
onDismiss={() => setShowModal(false)} onDismiss={toggelDelegateModal}
title={showUnlockVoting ? 'Unlock Votes' : 'Update Delegation'} title={showUnlockVoting ? 'Unlock Votes' : 'Update Delegation'}
/> />
<TopSection gap="md"> <TopSection gap="md">
...@@ -161,7 +166,7 @@ export default function Vote() { ...@@ -161,7 +166,7 @@ export default function Vote() {
style={{ width: 'fit-content' }} style={{ width: 'fit-content' }}
padding="8px" padding="8px"
borderRadius="8px" borderRadius="8px"
onClick={() => setShowModal(true)} onClick={toggelDelegateModal}
> >
Unlock Voting Unlock Voting
</ButtonPrimary> </ButtonPrimary>
...@@ -195,7 +200,7 @@ export default function Vote() { ...@@ -195,7 +200,7 @@ export default function Vote() {
> >
{userDelegatee === account ? 'Self' : shortenAddress(userDelegatee)} {userDelegatee === account ? 'Self' : shortenAddress(userDelegatee)}
</StyledExternalLink> </StyledExternalLink>
<TextButton onClick={() => setShowModal(true)} style={{ marginLeft: '4px' }}> <TextButton onClick={toggelDelegateModal} style={{ marginLeft: '4px' }}>
(edit) (edit)
</TextButton> </TextButton>
</AddressButton> </AddressButton>
......
...@@ -24,7 +24,9 @@ export enum ApplicationModal { ...@@ -24,7 +24,9 @@ export enum ApplicationModal {
SELF_CLAIM, SELF_CLAIM,
ADDRESS_CLAIM, ADDRESS_CLAIM,
CLAIM_POPUP, CLAIM_POPUP,
MENU MENU,
DELEGATE,
VOTE
} }
export const updateBlockNumber = createAction<{ chainId: number; blockNumber: number }>('application/updateBlockNumber') export const updateBlockNumber = createAction<{ chainId: number; blockNumber: number }>('application/updateBlockNumber')
......
...@@ -51,6 +51,14 @@ export function useToggleSelfClaimModal(): () => void { ...@@ -51,6 +51,14 @@ export function useToggleSelfClaimModal(): () => void {
return useToggleModal(ApplicationModal.SELF_CLAIM) return useToggleModal(ApplicationModal.SELF_CLAIM)
} }
export function useToggleDelegateModal(): () => void {
return useToggleModal(ApplicationModal.DELEGATE)
}
export function useToggleVoteModal(): () => void {
return useToggleModal(ApplicationModal.VOTE)
}
// returns a function that allows adding a popup // returns a function that allows adding a popup
export function useAddPopup(): (content: PopupContent, key?: string) => void { export function useAddPopup(): (content: PopupContent, key?: string) => void {
const dispatch = useDispatch() const dispatch = useDispatch()
......
...@@ -192,6 +192,10 @@ body { ...@@ -192,6 +192,10 @@ body {
padding: 0; padding: 0;
} }
a {
color: ${colors(false).blue1};
}
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment