@@ -17,8 +17,11 @@ import VoteModal from '../../components/vote/VoteModal'
1717import { TokenAmount , JSBI } from '@uniswap/sdk'
1818import { useTokenBalance } from '../../state/wallet/hooks'
1919import { useActiveWeb3React } from '../../hooks'
20- import { UNI , ZERO_ADDRESS , PROPOSAL_LENGTH_IN_DAYS } from '../../constants'
20+ import { UNI , ZERO_ADDRESS , PROPOSAL_LENGTH_IN_DAYS , COMMON_CONTRACT_NAMES } from '../../constants'
2121import { isAddress , getEtherscanLink } from '../../utils'
22+ import { ApplicationModal } from '../../state/application/actions'
23+ import { useModalOpen , useToggleDelegateModal , useToggleVoteModal } from '../../state/application/hooks'
24+ import DelegateModal from '../../components/vote/DelegateModal'
2225
2326const PageWrapper = styled ( AutoColumn ) `
2427 width: 100%;
@@ -108,7 +111,12 @@ export default function VotePage({
108111 const [ support , setSupport ] = useState < boolean > ( true )
109112
110113 // modal for casting votes
111- const [ showModal , setShowModal ] = useState < boolean > ( false )
114+ const showVoteModal = useModalOpen ( ApplicationModal . VOTE )
115+ const toggleVoteModal = useToggleVoteModal ( )
116+
117+ // toggle for showing delegation modal
118+ const showDelegateModal = useModalOpen ( ApplicationModal . DELEGATE )
119+ const toggelDelegateModal = useToggleDelegateModal ( )
112120
113121 // get and format date from data
114122 const startTimestamp : number | undefined = useTimestampFromBlock ( proposalData ?. startBlock )
@@ -133,21 +141,19 @@ export default function VotePage({
133141 )
134142
135143 // show links in propsoal details if content is an address
144+ // if content is contract with common name, replace address with common name
136145 const linkIfAddress = ( content : string ) => {
137146 if ( isAddress ( content ) && chainId ) {
138- return < ExternalLink href = { getEtherscanLink ( chainId , content , 'address' ) } > { content } </ ExternalLink >
147+ const commonName = COMMON_CONTRACT_NAMES [ content ] ?? content
148+ return < ExternalLink href = { getEtherscanLink ( chainId , content , 'address' ) } > { commonName } </ ExternalLink >
139149 }
140150 return < span > { content } </ span >
141151 }
142152
143153 return (
144154 < PageWrapper gap = "lg" justify = "center" >
145- < VoteModal
146- isOpen = { showModal }
147- onDismiss = { ( ) => setShowModal ( false ) }
148- proposalId = { proposalData ?. id }
149- support = { support }
150- />
155+ < VoteModal isOpen = { showVoteModal } onDismiss = { toggleVoteModal } proposalId = { proposalData ?. id } support = { support } />
156+ < DelegateModal isOpen = { showDelegateModal } onDismiss = { toggelDelegateModal } title = "Unlock Votes" />
151157 < ProposalInfo gap = "lg" justify = "start" >
152158 < RowBetween style = { { width : '100%' } } >
153159 < ArrowWrapper to = "/vote" >
@@ -162,15 +168,15 @@ export default function VotePage({
162168 { endDate && endDate < now
163169 ? 'Voting ended ' + ( endDate && endDate . toLocaleString ( DateTime . DATETIME_FULL ) )
164170 : proposalData
165- ? 'Voting ends approximately' + ( endDate && endDate . toLocaleString ( DateTime . DATETIME_FULL ) )
171+ ? 'Voting ends approximately ' + ( endDate && endDate . toLocaleString ( DateTime . DATETIME_FULL ) )
166172 : '' }
167173 </ TYPE . main >
168174 { showUnlockVoting && endDate && endDate > now && (
169175 < ButtonPrimary
170176 style = { { width : 'fit-content' } }
171177 padding = "8px"
172178 borderRadius = "8px"
173- onClick = { ( ) => setShowModal ( true ) }
179+ onClick = { toggelDelegateModal }
174180 >
175181 Unlock Voting
176182 </ ButtonPrimary >
@@ -188,7 +194,7 @@ export default function VotePage({
188194 borderRadius = "8px"
189195 onClick = { ( ) => {
190196 setSupport ( true )
191- setShowModal ( true )
197+ toggleVoteModal ( )
192198 } }
193199 >
194200 Vote For
@@ -198,7 +204,7 @@ export default function VotePage({
198204 borderRadius = "8px"
199205 onClick = { ( ) => {
200206 setSupport ( false )
201- setShowModal ( true )
207+ toggleVoteModal ( )
202208 } }
203209 >
204210 Vote Against
@@ -260,7 +266,7 @@ export default function VotePage({
260266 } ) }
261267 </ AutoColumn >
262268 < AutoColumn gap = "md" >
263- < TYPE . mediumHeader fontWeight = { 600 } > Overview </ TYPE . mediumHeader >
269+ < TYPE . mediumHeader fontWeight = { 600 } > Description </ TYPE . mediumHeader >
264270 < MarkDownWrapper >
265271 < ReactMarkdown source = { proposalData ?. description } />
266272 </ MarkDownWrapper >
0 commit comments