improve displayed proposal end time accuracy (#1173)

This commit is contained in:
Shane Fontaine 2020-10-19 07:14:56 -07:00 committed by GitHub
parent 50a599c005
commit 32ac25556b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

@ -20,8 +20,10 @@ export const MKR = new Token(ChainId.MAINNET, '0x9f8F72aA9304c8B593d555F12eF6589
export const AMPL = new Token(ChainId.MAINNET, '0xD46bA6D942050d489DBd938a2C909A5d5039A161', 9, 'AMPL', 'Ampleforth') export const AMPL = new Token(ChainId.MAINNET, '0xD46bA6D942050d489DBd938a2C909A5d5039A161', 9, 'AMPL', 'Ampleforth')
export const WBTC = new Token(ChainId.MAINNET, '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', 18, 'WBTC', 'Wrapped BTC') export const WBTC = new Token(ChainId.MAINNET, '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', 18, 'WBTC', 'Wrapped BTC')
// TODO this is only approximate, it's actually based on blocks // Block time here is slightly higher (~1s) than average in order to avoid ongoing proposals past the displayed time
export const PROPOSAL_LENGTH_IN_DAYS = 7 export const AVERAGE_BLOCK_TIME_IN_SECS = 14
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 GOVERNANCE_ADDRESS = '0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F' export const GOVERNANCE_ADDRESS = '0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F'

@ -16,7 +16,7 @@ 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_DAYS, COMMON_CONTRACT_NAMES, UNI, ZERO_ADDRESS } from '../../constants' import { PROPOSAL_LENGTH_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 } from '../../state/application/hooks'
@ -122,7 +122,7 @@ export default function VotePage({
// 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)
const endDate: DateTime | undefined = startTimestamp const endDate: DateTime | undefined = startTimestamp
? DateTime.fromSeconds(startTimestamp).plus({ days: PROPOSAL_LENGTH_IN_DAYS }) ? DateTime.fromSeconds(startTimestamp).plus({ seconds: PROPOSAL_LENGTH_IN_SECS })
: undefined : undefined
const now: DateTime = DateTime.local() const now: DateTime = DateTime.local()