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
5388cab7
Unverified
Commit
5388cab7
authored
Dec 21, 2020
by
Ian Lapham
Committed by
GitHub
Dec 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update vote timestamp estimation (#1242)
parent
cadd68fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
index.ts
src/constants/index.ts
+1
-1
VotePage.tsx
src/pages/Vote/VotePage.tsx
+14
-7
No files found.
src/constants/index.ts
View file @
5388cab7
...
@@ -23,7 +23,7 @@ export const AMPL = new Token(ChainId.MAINNET, '0xD46bA6D942050d489DBd938a2C909A
...
@@ -23,7 +23,7 @@ export const AMPL = new Token(ChainId.MAINNET, '0xD46bA6D942050d489DBd938a2C909A
export
const
WBTC
=
new
Token
(
ChainId
.
MAINNET
,
'
0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599
'
,
8
,
'
WBTC
'
,
'
Wrapped BTC
'
)
export
const
WBTC
=
new
Token
(
ChainId
.
MAINNET
,
'
0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599
'
,
8
,
'
WBTC
'
,
'
Wrapped BTC
'
)
// Block time here is slightly higher (~1s) than average in order to avoid ongoing proposals past the displayed time
// Block time here is slightly higher (~1s) than average in order to avoid ongoing proposals past the displayed time
export
const
AVERAGE_BLOCK_TIME_IN_SECS
=
1
4
export
const
AVERAGE_BLOCK_TIME_IN_SECS
=
1
3
export
const
PROPOSAL_LENGTH_IN_BLOCKS
=
40
_320
export
const
PROPOSAL_LENGTH_IN_BLOCKS
=
40
_320
export
const
PROPOSAL_LENGTH_IN_SECS
=
AVERAGE_BLOCK_TIME_IN_SECS
*
PROPOSAL_LENGTH_IN_BLOCKS
export
const
PROPOSAL_LENGTH_IN_SECS
=
AVERAGE_BLOCK_TIME_IN_SECS
*
PROPOSAL_LENGTH_IN_BLOCKS
...
...
src/pages/Vote/VotePage.tsx
View file @
5388cab7
...
@@ -10,19 +10,20 @@ import { ArrowLeft } from 'react-feather'
...
@@ -10,19 +10,20 @@ 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
{
useProposalData
,
useUserVotesAsOfBlock
,
ProposalData
,
useUserDelegatee
}
from
'
../../state/governance/hooks
'
import
{
useTimestampFromBlock
}
from
'
../../hooks/useTimestampFromBlock
'
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
'
import
{
TokenAmount
,
JSBI
}
from
'
@uniswap/sdk
'
import
{
TokenAmount
,
JSBI
}
from
'
@uniswap/sdk
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
PROPOSAL_LENGTH
_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
{
isAddress
,
getEtherscanLink
}
from
'
../../utils
'
import
{
ApplicationModal
}
from
'
../../state/application/actions
'
import
{
ApplicationModal
}
from
'
../../state/application/actions
'
import
{
useModalOpen
,
useToggleDelegateModal
,
useToggleVoteModal
}
from
'
../../state/application/hooks
'
import
{
useModalOpen
,
useToggleDelegateModal
,
useToggleVoteModal
,
useBlockNumber
}
from
'
../../state/application/hooks
'
import
DelegateModal
from
'
../../components/vote/DelegateModal
'
import
DelegateModal
from
'
../../components/vote/DelegateModal
'
import
{
GreyCard
}
from
'
../../components/Card
'
import
{
GreyCard
}
from
'
../../components/Card
'
import
{
useTokenBalance
}
from
'
../../state/wallet/hooks
'
import
{
useTokenBalance
}
from
'
../../state/wallet/hooks
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
{
BigNumber
}
from
'
ethers
'
const
PageWrapper
=
styled
(
AutoColumn
)
`
const
PageWrapper
=
styled
(
AutoColumn
)
`
width: 100%;
width: 100%;
...
@@ -124,10 +125,16 @@ export default function VotePage({
...
@@ -124,10 +125,16 @@ export default function VotePage({
const
toggelDelegateModal
=
useToggleDelegateModal
()
const
toggelDelegateModal
=
useToggleDelegateModal
()
// get and format date from data
// get and format date from data
const
startTimestamp
:
number
|
undefined
=
useTimestampFromBlock
(
proposalData
?.
startBlock
)
const
currentTimestamp
=
useCurrentBlockTimestamp
()
const
endDate
:
DateTime
|
undefined
=
startTimestamp
const
currentBlock
=
useBlockNumber
()
?
DateTime
.
fromSeconds
(
startTimestamp
).
plus
({
seconds
:
PROPOSAL_LENGTH_IN_SECS
})
const
endDate
:
DateTime
|
undefined
=
:
undefined
proposalData
&&
currentTimestamp
&&
currentBlock
?
DateTime
.
fromSeconds
(
currentTimestamp
.
add
(
BigNumber
.
from
(
AVERAGE_BLOCK_TIME_IN_SECS
).
mul
(
BigNumber
.
from
(
proposalData
.
endBlock
-
currentBlock
)))
.
toNumber
()
)
:
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
...
...
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