Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
4903258b
Unverified
Commit
4903258b
authored
May 03, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'main' into v3-main
# Conflicts: # src/pages/Vote/VotePage.tsx # src/pages/Vote/index.tsx
parents
4bc1b8eb
fe35ca9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
34 deletions
+51
-34
VotePage.tsx
src/pages/Vote/VotePage.tsx
+17
-9
index.tsx
src/pages/Vote/index.tsx
+10
-4
styled.tsx
src/pages/Vote/styled.tsx
+12
-16
hooks.ts
src/state/governance/hooks.ts
+12
-5
No files found.
src/pages/Vote/VotePage.tsx
View file @
4903258b
...
@@ -3,13 +3,19 @@ import { AutoColumn } from '../../components/Column'
...
@@ -3,13 +3,19 @@ import { AutoColumn } from '../../components/Column'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
RouteComponentProps
}
from
'
react-router-dom
'
import
{
RouteComponentProps
}
from
'
react-router-dom
'
import
{
TYPE
,
StyledInternalLink
,
ExternalLink
}
from
'
../../theme
'
import
{
ExternalLink
,
StyledInternalLink
,
TYPE
}
from
'
../../theme
'
import
{
Row
Fixed
,
RowBetween
}
from
'
../../components/Row
'
import
{
Row
Between
,
RowFixed
}
from
'
../../components/Row
'
import
{
CardSection
,
DataCard
}
from
'
../../components/earn/styled
'
import
{
CardSection
,
DataCard
}
from
'
../../components/earn/styled
'
import
{
ArrowLeft
}
from
'
react-feather
'
import
{
ArrowLeft
}
from
'
react-feather
'
import
{
ButtonPrimary
}
from
'
../../components/Button
'
import
{
ButtonPrimary
}
from
'
../../components/Button
'
import
{
ProposalStatus
}
from
'
./styled
'
import
{
ProposalStatus
}
from
'
./styled
'
import
{
useProposalData
,
useUserVotesAsOfBlock
,
ProposalData
,
useUserDelegatee
}
from
'
../../state/governance/hooks
'
import
{
ProposalData
,
ProposalState
,
useProposalData
,
useUserDelegatee
,
useUserVotesAsOfBlock
,
}
from
'
../../state/governance/hooks
'
import
{
DateTime
}
from
'
luxon
'
import
{
DateTime
}
from
'
luxon
'
import
ReactMarkdown
from
'
react-markdown
'
import
ReactMarkdown
from
'
react-markdown
'
import
VoteModal
from
'
../../components/vote/VoteModal
'
import
VoteModal
from
'
../../components/vote/VoteModal
'
...
@@ -17,14 +23,14 @@ import { TokenAmount } from '@uniswap/sdk-core'
...
@@ -17,14 +23,14 @@ import { TokenAmount } from '@uniswap/sdk-core'
import
{
JSBI
}
from
'
@uniswap/v2-sdk
'
import
{
JSBI
}
from
'
@uniswap/v2-sdk
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
AVERAGE_BLOCK_TIME_IN_SECS
,
COMMON_CONTRACT_NAMES
,
UNI
,
ZERO_ADDRESS
}
from
'
../../constants
'
import
{
AVERAGE_BLOCK_TIME_IN_SECS
,
COMMON_CONTRACT_NAMES
,
UNI
,
ZERO_ADDRESS
}
from
'
../../constants
'
import
{
isAddress
,
getEtherscanLink
}
from
'
../../utils
'
import
{
getEtherscanLink
,
isAddress
}
from
'
../../utils
'
import
{
ApplicationModal
}
from
'
../../state/application/actions
'
import
{
ApplicationModal
}
from
'
../../state/application/actions
'
import
{
use
ModalOpen
,
useToggleDelegateModal
,
useToggleVoteModal
,
useBlockNumber
}
from
'
../../state/application/hooks
'
import
{
use
BlockNumber
,
useModalOpen
,
useToggleDelegateModal
,
useToggleVoteModal
}
from
'
../../state/application/hooks
'
import
DelegateModal
from
'
../../components/vote/DelegateModal
'
import
DelegateModal
from
'
../../components/vote/DelegateModal
'
import
{
GreyCard
}
from
'
../../components/Card
'
import
{
useTokenBalance
}
from
'
../../state/wallet/hooks
'
import
{
useTokenBalance
}
from
'
../../state/wallet/hooks
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
{
BigNumber
}
from
'
ethers
'
import
{
BigNumber
}
from
'
ethers
'
import
{
GreyCard
}
from
'
../../components/Card
'
const
PageWrapper
=
styled
(
AutoColumn
)
`
const
PageWrapper
=
styled
(
AutoColumn
)
`
width: 100%;
width: 100%;
...
@@ -153,7 +159,7 @@ export default function VotePage({
...
@@ -153,7 +159,7 @@ export default function VotePage({
availableVotes
&&
availableVotes
&&
JSBI
.
greaterThan
(
availableVotes
.
raw
,
JSBI
.
BigInt
(
0
))
&&
JSBI
.
greaterThan
(
availableVotes
.
raw
,
JSBI
.
BigInt
(
0
))
&&
proposalData
&&
proposalData
&&
proposalData
.
status
===
'
active
'
proposalData
.
status
===
ProposalState
.
Active
const
uniBalance
:
TokenAmount
|
undefined
=
useTokenBalance
(
account
??
undefined
,
chainId
?
UNI
[
chainId
]
:
undefined
)
const
uniBalance
:
TokenAmount
|
undefined
=
useTokenBalance
(
account
??
undefined
,
chainId
?
UNI
[
chainId
]
:
undefined
)
const
userDelegatee
:
string
|
undefined
=
useUserDelegatee
()
const
userDelegatee
:
string
|
undefined
=
useUserDelegatee
()
...
@@ -182,7 +188,9 @@ export default function VotePage({
...
@@ -182,7 +188,9 @@ export default function VotePage({
<
ArrowWrapper
to=
"/vote"
>
<
ArrowWrapper
to=
"/vote"
>
<
ArrowLeft
size=
{
20
}
/>
All Proposals
<
ArrowLeft
size=
{
20
}
/>
All Proposals
</
ArrowWrapper
>
</
ArrowWrapper
>
{
proposalData
&&
<
ProposalStatus
status=
{
proposalData
?.
status
??
''
}
>
{
proposalData
?.
status
}
</
ProposalStatus
>
}
{
proposalData
&&
(
<
ProposalStatus
status=
{
proposalData
.
status
}
>
{
ProposalState
[
proposalData
.
status
]
}
</
ProposalStatus
>
)
}
</
RowBetween
>
</
RowBetween
>
<
AutoColumn
gap=
"10px"
style=
{
{
width
:
'
100%
'
}
}
>
<
AutoColumn
gap=
"10px"
style=
{
{
width
:
'
100%
'
}
}
>
<
TYPE
.
largeHeader
style=
{
{
marginBottom
:
'
.5rem
'
}
}
>
{
proposalData
?.
title
}
</
TYPE
.
largeHeader
>
<
TYPE
.
largeHeader
style=
{
{
marginBottom
:
'
.5rem
'
}
}
>
{
proposalData
?.
title
}
</
TYPE
.
largeHeader
>
...
@@ -195,7 +203,7 @@ export default function VotePage({
...
@@ -195,7 +203,7 @@ export default function VotePage({
:
''
}
:
''
}
</
TYPE
.
main
>
</
TYPE
.
main
>
</
RowBetween
>
</
RowBetween
>
{
proposalData
&&
proposalData
.
status
===
'
active
'
&&
!
showVotingButtons
&&
(
{
proposalData
&&
proposalData
.
status
===
ProposalState
.
Active
&&
!
showVotingButtons
&&
(
<
GreyCard
>
<
GreyCard
>
<
TYPE
.
black
>
<
TYPE
.
black
>
Only UNI votes that were self delegated or delegated to another address before block
{
'
'
}
Only UNI votes that were self delegated or delegated to another address before block
{
'
'
}
...
...
src/pages/Vote/index.tsx
View file @
4903258b
import
React
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
{
ExternalLink
,
TYPE
}
from
'
../../theme
'
import
{
RowBetween
,
RowFixed
}
from
'
../../components/Row
'
import
{
RowBetween
,
RowFixed
}
from
'
../../components/Row
'
import
{
Link
}
from
'
react-router-dom
'
import
{
Link
}
from
'
react-router-dom
'
import
{
ProposalStatus
}
from
'
./styled
'
import
{
ProposalStatus
}
from
'
./styled
'
import
{
ButtonPrimary
}
from
'
../../components/Button
'
import
{
ButtonPrimary
}
from
'
../../components/Button
'
import
{
Button
}
from
'
rebass/styled-components
'
import
{
Button
}
from
'
rebass/styled-components
'
import
{
darken
}
from
'
polished
'
import
{
darken
}
from
'
polished
'
import
{
CardSection
,
DataCard
,
CardNoise
,
CardBGImage
}
from
'
../../components/earn/styled
'
import
{
CardBGImage
,
CardNoise
,
CardSection
,
DataCard
}
from
'
../../components/earn/styled
'
import
{
useAllProposalData
,
ProposalData
,
useUserVotes
,
useUserDelegatee
}
from
'
../../state/governance/hooks
'
import
{
ProposalData
,
ProposalState
,
useAllProposalData
,
useUserDelegatee
,
useUserVotes
,
}
from
'
../../state/governance/hooks
'
import
DelegateModal
from
'
../../components/vote/DelegateModal
'
import
DelegateModal
from
'
../../components/vote/DelegateModal
'
import
{
useTokenBalance
}
from
'
../../state/wallet/hooks
'
import
{
useTokenBalance
}
from
'
../../state/wallet/hooks
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
...
@@ -223,7 +229,7 @@ export default function Vote() {
...
@@ -223,7 +229,7 @@ export default function Vote() {
<
Proposal
as=
{
Link
}
to=
{
'
/vote/
'
+
p
.
id
}
key=
{
i
}
>
<
Proposal
as=
{
Link
}
to=
{
'
/vote/
'
+
p
.
id
}
key=
{
i
}
>
<
ProposalNumber
>
{
p
.
id
}
</
ProposalNumber
>
<
ProposalNumber
>
{
p
.
id
}
</
ProposalNumber
>
<
ProposalTitle
>
{
p
.
title
}
</
ProposalTitle
>
<
ProposalTitle
>
{
p
.
title
}
</
ProposalTitle
>
<
ProposalStatus
status=
{
p
.
status
}
>
{
p
.
status
}
</
ProposalStatus
>
<
ProposalStatus
status=
{
p
.
status
}
>
{
ProposalState
[
p
.
status
]
}
</
ProposalStatus
>
</
Proposal
>
</
Proposal
>
)
)
})
}
})
}
...
...
src/pages/Vote/styled.tsx
View file @
4903258b
import
styled
from
'
styled-components
'
import
styled
,
{
DefaultTheme
}
from
'
styled-components
'
import
{
ProposalState
}
from
'
../../state/governance/hooks
'
const
handleColorType
=
(
status
?:
any
,
theme
?:
any
)
=>
{
const
handleColorType
=
(
status
:
ProposalState
,
theme
:
DefaultTheme
)
=>
{
switch
(
status
)
{
switch
(
status
)
{
case
'
pending
'
:
case
ProposalState
.
Pending
:
case
ProposalState
.
Active
:
return
theme
.
blue1
return
theme
.
blue1
case
'
active
'
:
case
ProposalState
.
Succeeded
:
return
theme
.
blue1
case
ProposalState
.
Executed
:
case
'
succeeded
'
:
return
theme
.
green1
return
theme
.
green1
case
'
defeated
'
:
case
ProposalState
.
Defeated
:
return
theme
.
red1
return
theme
.
red1
case
'
queued
'
:
case
ProposalState
.
Queued
:
return
theme
.
text3
case
ProposalState
.
Canceled
:
case
'
executed
'
:
case
ProposalState
.
Expired
:
return
theme
.
green1
case
'
canceled
'
:
return
theme
.
text3
case
'
expired
'
:
return
theme
.
text3
default
:
default
:
return
theme
.
text3
return
theme
.
text3
}
}
}
}
export
const
ProposalStatus
=
styled
.
span
<
{
status
:
string
}
>
`
export
const
ProposalStatus
=
styled
.
span
<
{
status
:
ProposalState
}
>
`
font-size: 0.825rem;
font-size: 0.825rem;
font-weight: 600;
font-weight: 600;
padding: 0.5rem;
padding: 0.5rem;
...
...
src/state/governance/hooks.ts
View file @
4903258b
...
@@ -22,7 +22,7 @@ export interface ProposalData {
...
@@ -22,7 +22,7 @@ export interface ProposalData {
title
:
string
title
:
string
description
:
string
description
:
string
proposer
:
string
proposer
:
string
status
:
string
status
:
ProposalState
forCount
:
number
forCount
:
number
againstCount
:
number
againstCount
:
number
startBlock
:
number
startBlock
:
number
...
@@ -30,9 +30,16 @@ export interface ProposalData {
...
@@ -30,9 +30,16 @@ export interface ProposalData {
details
:
ProposalDetail
[]
details
:
ProposalDetail
[]
}
}
const
enumerateProposalState
=
(
state
:
number
)
=>
{
export
enum
ProposalState
{
const
proposalStates
=
[
'
pending
'
,
'
active
'
,
'
canceled
'
,
'
defeated
'
,
'
succeeded
'
,
'
queued
'
,
'
expired
'
,
'
executed
'
]
Undetermined
=
-
1
,
return
proposalStates
[
state
]
Pending
,
Active
,
Canceled
,
Defeated
,
Succeeded
,
Queued
,
Expired
,
Executed
}
}
// get count of all proposals made
// get count of all proposals made
...
@@ -129,7 +136,7 @@ export function useAllProposalData() {
...
@@ -129,7 +136,7 @@ export function useAllProposalData() {
title
:
description
?.
split
(
/# |
\n
/g
)[
1
]
||
'
Untitled
'
,
title
:
description
?.
split
(
/# |
\n
/g
)[
1
]
||
'
Untitled
'
,
description
:
description
||
'
No description.
'
,
description
:
description
||
'
No description.
'
,
proposer
:
allProposals
[
i
]?.
result
?.
proposer
,
proposer
:
allProposals
[
i
]?.
result
?.
proposer
,
status
:
enumerateProposalState
(
allProposalStates
[
i
]?.
result
?.[
0
])
??
'
Undetermined
'
,
status
:
allProposalStates
[
i
]?.
result
?.[
0
]
??
ProposalState
.
Undetermined
,
forCount
:
parseFloat
(
ethers
.
utils
.
formatUnits
(
allProposals
[
i
]?.
result
?.
forVotes
.
toString
(),
18
)),
forCount
:
parseFloat
(
ethers
.
utils
.
formatUnits
(
allProposals
[
i
]?.
result
?.
forVotes
.
toString
(),
18
)),
againstCount
:
parseFloat
(
ethers
.
utils
.
formatUnits
(
allProposals
[
i
]?.
result
?.
againstVotes
.
toString
(),
18
)),
againstCount
:
parseFloat
(
ethers
.
utils
.
formatUnits
(
allProposals
[
i
]?.
result
?.
againstVotes
.
toString
(),
18
)),
startBlock
:
parseInt
(
allProposals
[
i
]?.
result
?.
startBlock
?.
toString
()),
startBlock
:
parseInt
(
allProposals
[
i
]?.
result
?.
startBlock
?.
toString
()),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment