From e693e40d1f881e80cec466b42d7355ce1066e619 Mon Sep 17 00:00:00 2001 From: Atatakai Date: Thu, 1 Aug 2024 10:58:24 +0400 Subject: [PATCH 1/2] (govern) fix: update state after voting, fix rollover pool sorting, add next week explanation --- apps/govern/common-util/constants/scopeKeys.ts | 2 ++ .../components/Contracts/ContractsList.tsx | 10 ++-------- .../Contracts/EditVotes/index.spec.tsx | 3 ++- .../components/Contracts/EditVotes/index.tsx | 4 +++- .../Contracts/MyVotingWeight/Votes.tsx | 10 +++------- apps/govern/components/NextWeekTooltip.tsx | 16 ++++++++++++++-- .../govern/hooks/useFetchStakingContractsList.ts | 3 ++- apps/govern/store/govern.ts | 4 +--- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/apps/govern/common-util/constants/scopeKeys.ts b/apps/govern/common-util/constants/scopeKeys.ts index 56095b15..495444d3 100644 --- a/apps/govern/common-util/constants/scopeKeys.ts +++ b/apps/govern/common-util/constants/scopeKeys.ts @@ -3,6 +3,7 @@ export const VOTE_USER_POWER_KEY = 'voteUserPower'; export const NEXT_USERS_SLOPES_KEY = 'nextUserSlopes'; export const NEXT_RELATIVE_WEIGHTS_KEY = 'nextRelativeWeights'; export const LATEST_BLOCK_KEY = 'latestBlock'; +export const TIME_SUM_KEY = 'timeSum'; export const INVALIDATE_AFTER_UPDATE_KEYS = [ LAST_USER_VOTE_KEY, @@ -10,6 +11,7 @@ export const INVALIDATE_AFTER_UPDATE_KEYS = [ NEXT_USERS_SLOPES_KEY, NEXT_RELATIVE_WEIGHTS_KEY, LATEST_BLOCK_KEY, + TIME_SUM_KEY, ]; export const INVALIDATE_AFTER_ACCOUNT_CHANGE = [ diff --git a/apps/govern/components/Contracts/ContractsList.tsx b/apps/govern/components/Contracts/ContractsList.tsx index 5e7870b2..4c0249bb 100644 --- a/apps/govern/components/Contracts/ContractsList.tsx +++ b/apps/govern/components/Contracts/ContractsList.tsx @@ -1,11 +1,10 @@ -import { CheckOutlined, InfoCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { CheckOutlined, PlusOutlined } from '@ant-design/icons'; import { Button, Card as CardAntd, Space, Table, Typography } from 'antd'; import { ColumnsType } from 'antd/es/table'; import styled from 'styled-components'; import { Allocation, StakingContract } from 'types'; import { useAccount } from 'wagmi'; -import { COLOR } from 'libs/ui-theme/src'; import { CHAIN_NAMES } from 'libs/util-constants/src'; import { formatWeiBalance } from 'common-util/functions/balance'; @@ -65,12 +64,7 @@ const getColumns = ({ ), }, { - title: ( - - Next week's weight - - - ), + title: Next week's weight, key: 'nextWeight', dataIndex: 'nextWeight', render: (nextWeight) => ( diff --git a/apps/govern/components/Contracts/EditVotes/index.spec.tsx b/apps/govern/components/Contracts/EditVotes/index.spec.tsx index c5ee8b44..10e46f26 100644 --- a/apps/govern/components/Contracts/EditVotes/index.spec.tsx +++ b/apps/govern/components/Contracts/EditVotes/index.spec.tsx @@ -88,8 +88,9 @@ describe('', () => { expect(screen.getByText('My voting weight')).toBeInTheDocument(); expect( - screen.getByText(/New voting weight will take effect at the beginning of the next week./), + screen.getByText(/Updated voting weights will take effect at the start of/), ).toBeInTheDocument(); + expect(screen.getByText(/next Unix time week./)).toBeInTheDocument(); }); describe('Voting contract row', () => { diff --git a/apps/govern/components/Contracts/EditVotes/index.tsx b/apps/govern/components/Contracts/EditVotes/index.tsx index b1f5e488..2789bcb2 100644 --- a/apps/govern/components/Contracts/EditVotes/index.tsx +++ b/apps/govern/components/Contracts/EditVotes/index.tsx @@ -13,6 +13,7 @@ import { RETAINER_ADDRESS } from 'common-util/constants/addresses'; import { INVALIDATE_AFTER_UPDATE_KEYS } from 'common-util/constants/scopeKeys'; import { getBytes32FromAddress } from 'common-util/functions/addresses'; import { voteForNomineeWeights } from 'common-util/functions/requests'; +import { NextWeekTooltip } from 'components/NextWeekTooltip'; import { queryClient } from 'context/Web3ModalProvider'; import { clearState } from 'store/govern'; import { useAppDispatch, useAppSelector } from 'store/index'; @@ -218,7 +219,8 @@ export const EditVotes = ({ allocations, setAllocations, setIsUpdating }: EditVo /> - New voting weight will take effect at the beginning of the next week. + Updated voting weights will take effect at the start of  + next Unix time week.