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
60bd0eb8
Unverified
Commit
60bd0eb8
authored
Nov 03, 2021
by
Noah Zinsmeister
Committed by
GitHub
Nov 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add proposal start time (#2738)
parent
188b321c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
15 deletions
+37
-15
VotePage.tsx
src/pages/Vote/VotePage.tsx
+37
-15
No files found.
src/pages/Vote/VotePage.tsx
View file @
60bd0eb8
...
@@ -122,6 +122,21 @@ const ProposerAddressLink = styled(ExternalLink)`
...
@@ -122,6 +122,21 @@ const ProposerAddressLink = styled(ExternalLink)`
word-break: break-all;
word-break: break-all;
`
`
function
getDateFromBlock
(
targetBlock
:
number
|
undefined
,
currentBlock
:
number
|
undefined
,
averageBlockTimeInSeconds
:
number
|
undefined
,
currentTimestamp
:
BigNumber
|
undefined
):
DateTime
|
undefined
{
return
targetBlock
&&
currentBlock
&&
averageBlockTimeInSeconds
&&
currentTimestamp
?
DateTime
.
fromSeconds
(
currentTimestamp
.
add
(
BigNumber
.
from
(
averageBlockTimeInSeconds
).
mul
(
BigNumber
.
from
(
targetBlock
-
currentBlock
)))
.
toNumber
()
)
:
undefined
}
export
default
function
VotePage
({
export
default
function
VotePage
({
match
:
{
match
:
{
params
:
{
governorIndex
,
id
},
params
:
{
governorIndex
,
id
},
...
@@ -146,18 +161,18 @@ export default function VotePage({
...
@@ -146,18 +161,18 @@ export default function VotePage({
// get and format date from data
// get and format date from data
const
currentTimestamp
=
useCurrentBlockTimestamp
()
const
currentTimestamp
=
useCurrentBlockTimestamp
()
const
currentBlock
=
useBlockNumber
()
const
currentBlock
=
useBlockNumber
()
const
endDate
:
DateTime
|
undefined
=
const
startDate
:
DateTime
|
undefined
=
getDateFromBlock
(
proposalData
&&
currentTimestamp
&&
currentBlock
proposalData
?.
startBlock
,
?
DateTime
.
fromSeconds
(
currentBlock
,
currentTimestamp
(
chainId
&&
AVERAGE_BLOCK_TIME_IN_SECS
[
chainId
])
??
DEFAULT_AVERAGE_BLOCK_TIME_IN_SECS
,
.
add
(
currentTimestamp
BigNumber
.
from
(
)
(
chainId
&&
AVERAGE_BLOCK_TIME_IN_SECS
[
chainId
])
??
DEFAULT_AVERAGE_BLOCK_TIME_IN_SECS
const
endDate
:
DateTime
|
undefined
=
getDateFromBlock
(
).
mul
(
BigNumber
.
from
(
proposalData
.
endBlock
-
currentBlock
))
proposalData
?.
endBlock
,
)
currentBlock
,
.
toNumber
()
(
chainId
&&
AVERAGE_BLOCK_TIME_IN_SECS
[
chainId
])
??
DEFAULT_AVERAGE_BLOCK_TIME_IN_SECS
,
)
currentTimestamp
:
undefined
)
const
now
:
DateTime
=
DateTime
.
local
()
const
now
:
DateTime
=
DateTime
.
local
()
// get total votes and format percentages for UI
// get total votes and format percentages for UI
...
@@ -223,14 +238,21 @@ export default function VotePage({
...
@@ -223,14 +238,21 @@ export default function VotePage({
</
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
>
<
RowBetween
>
<
TYPE
.
main
>
{
startDate
&&
startDate
>
now
?
(
<
Trans
>
Voting starts approximately
{
startDate
&&
startDate
.
toLocaleString
(
DateTime
.
DATETIME_FULL
)
}
</
Trans
>
)
:
null
}
</
TYPE
.
main
>
</
RowBetween
>
<
RowBetween
>
<
RowBetween
>
<
TYPE
.
main
>
<
TYPE
.
main
>
{
endDate
&&
endDate
<
now
?
(
{
endDate
&&
endDate
<
now
?
(
<
Trans
>
Voting ended
{
endDate
&&
endDate
.
toLocaleString
(
DateTime
.
DATETIME_FULL
)
}
</
Trans
>
<
Trans
>
Voting ended
{
endDate
&&
endDate
.
toLocaleString
(
DateTime
.
DATETIME_FULL
)
}
</
Trans
>
)
:
proposalData
?
(
<
Trans
>
Voting ends approximately
{
endDate
&&
endDate
.
toLocaleString
(
DateTime
.
DATETIME_FULL
)
}
</
Trans
>
)
:
(
)
:
(
''
<
Trans
>
Voting ends approximately
{
endDate
&&
endDate
.
toLocaleString
(
DateTime
.
DATETIME_FULL
)
}
</
Trans
>
)
}
)
}
</
TYPE
.
main
>
</
TYPE
.
main
>
</
RowBetween
>
</
RowBetween
>
...
...
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