diff --git a/.env.dev b/.env.dev index 8abeaed4..8c8f5bb0 100644 --- a/.env.dev +++ b/.env.dev @@ -4,9 +4,9 @@ NEXT_PUBLIC_EXPLORER=https://explorer.testnet.rootstock.io NEXT_PUBLIC_BUILD_ID= NEXT_PUBLIC_RIF_ADDRESS=0x19f64674d8a5b4e652319f5e239efd3bc969a1fe -NEXT_PUBLIC_STRIF_ADDRESS=0x7C19923bac1b41e9bBD1c33815A61854beeD9b54 -NEXT_PUBLIC_GOVERNOR_ADDRESS=0x0DB02C99619bB0E6d2cBeF5545Cc968DAb724E10 -NEXT_PUBLIC_EA_NFT_ADDRESS=0xa060A65967cb9b9511E3A4ec091Aa81c6dCe6662 +NEXT_PUBLIC_STRIF_ADDRESS=0xC4b091d97AD25ceA5922f09fe80711B7ACBbb16f +NEXT_PUBLIC_GOVERNOR_ADDRESS=0xB1A39B8f57A55d1429324EEb1564122806eb297F +NEXT_PUBLIC_EA_NFT_ADDRESS=0x979deF73ec80B8AE24Ae46765b81D9aF7b1C9327 NEXT_PUBLIC_MULTICALL_ADDRESS=0xcA11bde05977b3631167028862bE2a173976CA11 NEXT_PUBLIC_GRANTS_BUCKET_ADDRESS=0xfaca664c661af7e0e630c8f92b401012cd2a30ef NEXT_PUBLIC_GRANTS_ACTIVE_BUCKET_ADDRESS=0x2217E4d3Ae0A6E30075D1B5a7b8C1520E8009f49 diff --git a/src/app/proposals/TimeRemainingColumn.tsx b/src/app/proposals/TimeRemainingColumn.tsx index 181f4b9e..c165820f 100644 --- a/src/app/proposals/TimeRemainingColumn.tsx +++ b/src/app/proposals/TimeRemainingColumn.tsx @@ -13,13 +13,23 @@ const convertToTimeRemaining = (seconds: number) => { return `${days}d ${hours}h ${minutes}m ${remainingSeconds}s` } +/** + * This helps to render the right hook due to how Wagmi works... + * If the status is not active, there is no point in fetching the status of the vote + */ +const HOOK_TO_USE = { + dummy: (proposalId: string, number: bigint) => ({ + blocksUntilClosure: 0, + proposalDeadlineBlock: undefined, + }), + real: useGetProposalDeadline, +} + export const TimeRemainingColumn = () => { const { latestBlockNumber } = useSharedProposalsTableContext() - const { proposalId, blockNumber } = useProposalContext() - const { blocksUntilClosure, proposalDeadlineBlock } = useGetProposalDeadline( - proposalId, - latestBlockNumber || BigInt(1), - ) + const { proposalId, blockNumber, proposalStateHuman } = useProposalContext() + const hookToUse = HOOK_TO_USE[proposalStateHuman === 'Active' ? 'real' : 'dummy'] + const { blocksUntilClosure, proposalDeadlineBlock } = hookToUse(proposalId, latestBlockNumber || BigInt(1)) const votingWindowBlocks = BigInt(proposalDeadlineBlock || 1) - BigInt(blockNumber) const ratio = Number(blocksUntilClosure) / Number(votingWindowBlocks)