From 11855e905c32e6d960f2e856284d26d2fdaa8193 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Thu, 14 Oct 2021 06:11:01 +0100 Subject: [PATCH 01/34] :zap: Disable add votes button on banned delegates profile --- .../screens/wallet/overview/balanceInfo/balanceInfo.css | 7 +++++++ .../screens/wallet/overview/balanceInfo/index.js | 3 ++- src/components/screens/wallet/overview/index.js | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css b/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css index 36b234da00..c9621ec13b 100644 --- a/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css +++ b/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css @@ -84,6 +84,13 @@ } } + & .voteButton { + cursor: not-allowed; + opacity: 0.5; + color: gray; + font-weight: 100; + } + & .sendButton { &.LSK { background-color: var(--color-ultramarine-blue); diff --git a/src/components/screens/wallet/overview/balanceInfo/index.js b/src/components/screens/wallet/overview/balanceInfo/index.js index aa5ddb6ea3..8a2ff68493 100644 --- a/src/components/screens/wallet/overview/balanceInfo/index.js +++ b/src/components/screens/wallet/overview/balanceInfo/index.js @@ -16,7 +16,7 @@ import LockedBalanceLink from './unlocking'; import styles from './balanceInfo.css'; const BalanceInfo = ({ - t, activeToken, balance, isWalletRoute, address, username, + t, activeToken, balance, isWalletRoute, address, username, isBanned, }) => { const vote = useSelector(state => state.voting[address]); const initialValue = isWalletRoute @@ -59,6 +59,7 @@ const BalanceInfo = ({ {voteButtonTitle} diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 7e035ff8b4..3983b642ba 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -62,6 +62,7 @@ const Overview = ({ isWalletRoute={isWalletRoute} username={account?.dpos?.delegate?.username} address={address} + isBanned={account?.dpos?.delegate?.isBanned} />
From 00215f43beff765487d4342cdbf7eda5db9e6647 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Thu, 14 Oct 2021 06:21:02 +0100 Subject: [PATCH 02/34] :recycle: Update add vote button styling --- .../screens/wallet/overview/balanceInfo/balanceInfo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css b/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css index c9621ec13b..f2c52d17ce 100644 --- a/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css +++ b/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css @@ -84,7 +84,7 @@ } } - & .voteButton { + & .voteButton:disabled { cursor: not-allowed; opacity: 0.5; color: gray; From 6c838e1415ed7af41cbbb502ffc268aba5ffbfd9 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Mon, 18 Oct 2021 13:23:26 +0100 Subject: [PATCH 03/34] :zap: Design warning notification for punished delegates --- i18n/locales/en/common.json | 2 + .../wallet/overview/balanceInfo/index.js | 73 ++++++++++++------- .../screens/wallet/overview/index.js | 63 ++++++++++++---- .../warnPunishedDelegate.css | 35 +++++++++ .../warnPunishedDelegate.js | 40 ++++++++++ 5 files changed, 171 insertions(+), 42 deletions(-) create mode 100644 src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css create mode 100644 src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index 93869f6846..f9f8d7adb4 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -551,6 +551,7 @@ "Vote aborted on device": "Vote aborted on device", "Vote amount": "Vote amount", "Vote amount (LSK)": "Vote amount (LSK)", + "Vote for delegate": "Vote for delegate", "Vote submission failed": "Vote submission failed", "Voted delegates": "Voted delegates", "Voter": "Voter", @@ -589,6 +590,7 @@ "You can only vote in multiplies of 10 LSK.": "You can only vote in multiplies of 10 LSK.", "You can share your Lisk ID with anyone you wish, but never reveal your passphrase to anyone as it would allow full access to your account.": "You can share your Lisk ID with anyone you wish, but never reveal your passphrase to anyone as it would allow full access to your account.", "You can't vote for more than 10 delegates.": "You can't vote for more than 10 delegates.", + "You cannot vote for this delegate": "You cannot vote for this delegate", "You don't have enough LSK in your account.": "You don't have enough LSK in your account.", "You don’t have any bookmarks yet.": "You don’t have any bookmarks yet.", "You have already registered as a delegate.": "You have already registered as a delegate.", diff --git a/src/components/screens/wallet/overview/balanceInfo/index.js b/src/components/screens/wallet/overview/balanceInfo/index.js index 8a2ff68493..a78d10dfe7 100644 --- a/src/components/screens/wallet/overview/balanceInfo/index.js +++ b/src/components/screens/wallet/overview/balanceInfo/index.js @@ -8,6 +8,7 @@ import { PrimaryButton, SecondaryButton } from '@toolbox/buttons'; import Box from '@toolbox/box'; import BoxContent from '@toolbox/box/content'; import DialogLink from '@toolbox/dialog/link'; +import Tooltip from '@toolbox/tooltip/tooltip'; import LiskAmount from '@shared/liskAmount'; import DiscreetMode from '@shared/discreetMode'; import Converter from '@shared/converter'; @@ -16,12 +17,16 @@ import LockedBalanceLink from './unlocking'; import styles from './balanceInfo.css'; const BalanceInfo = ({ - t, activeToken, balance, isWalletRoute, address, username, isBanned, + t, + activeToken, + balance, + isWalletRoute, + address, + username, + isBanned, }) => { - const vote = useSelector(state => state.voting[address]); - const initialValue = isWalletRoute - ? {} - : { recipient: address }; + const vote = useSelector((state) => state.voting[address]); + const initialValue = isWalletRoute ? {} : { recipient: address }; const voteButtonTitle = vote ? t('Edit vote') : t('Add to votes'); @@ -42,31 +47,48 @@ const BalanceInfo = ({ value={fromRawLsk(balance)} error="" /> -
- { - activeToken === tokenMap.LSK.key && isWalletRoute ? ( - - ) : null - } + {activeToken === tokenMap.LSK.key && isWalletRoute ? ( + + ) : null}
- { - username ? ( - - - {voteButtonTitle} - - - ) : null - } - + {username ? ( + + + {voteButtonTitle} + + )} + > +

+ {isBanned + ? t('You cannot vote for this delegate') + : t('Vote for delegate')} +

+
+
+ ) : null} +
- ); diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 3983b642ba..e67a925b86 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -4,31 +4,42 @@ import { compose } from 'redux'; import { withTranslation } from 'react-i18next'; import grid from 'flexboxgrid/dist/flexboxgrid.css'; import withData from '@utils/withData'; +import { addSearchParamsToUrl } from '@utils/searchParams'; import { getTransactions } from '@api/transaction'; import { selectTransactions } from '@store/selectors'; +import FlashMessageHolder from '@toolbox/flashMessage/holder'; +import WarnPunishedDelegate from '@shared/warnPunishedDelegate/warnPunishedDelegate'; import BalanceChart from './balanceChart'; import AccountInfo from './accountInfo'; import BalanceInfo from './balanceInfo'; import styles from './overview.css'; const Overview = ({ - t, activeToken, transactions, hwInfo, - discreetMode, isWalletRoute, account, + t, + activeToken, + transactions, + hwInfo, + discreetMode, + isWalletRoute, + account, }) => { const { - address, publicKey, balance = 0, isMultisignature, + address, + publicKey, + balance = 0, + isMultisignature, } = account?.summary ?? {}; const { confirmed } = useSelector(selectTransactions); - const bookmark = useSelector( - state => state.bookmarks[activeToken].find(item => (item.address === address)), - ); + const bookmark = useSelector((state) => + state.bookmarks[activeToken].find((item) => item.address === address)); const host = useSelector( - state => ( - state.account - && state.account.info - && state.account.info[activeToken] - && state.account.info[activeToken].summary?.address) || '', + (state) => + (state.account + && state.account.info + && state.account.info[activeToken] + && state.account.info[activeToken].summary?.address) + || '', ); useEffect(() => { @@ -37,9 +48,24 @@ const Overview = ({ } }, [address]); + const readMore = () => { + addSearchParamsToUrl({ modal: 'readMore' }); + }; + return (
-
+ { + FlashMessageHolder.addMessage( + , + 'WarnPunishedDelegate', + ) + } +
-
+
-
+
{address && ( getTransactions({ network, params }, token), - getApiParams: state => ({ + apiUtil: (network, { token, ...params }) => + getTransactions({ network, params }, token), + getApiParams: (state) => ({ token: state.settings.token.active, }), defaultData: { data: [], meta: {} }, diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css new file mode 100644 index 0000000000..452d6c69fc --- /dev/null +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css @@ -0,0 +1,35 @@ +.flashContainer { + background-color: var(--color-warning-bg); + border-color: var(--color-warning-border); + border-width: 1px; +} + +.container { + display: flex; + justify-content: flex-start; + align-items: center; + width: 100%; + font-size: 18px; +} + +.btnContainer { + display: flex; + margin-left: auto; +} + +.button { + height: auto !important; + padding: 15px 20px !important; + margin-left: 12px; + border-radius: 5px; + border-color: var(--color-zodiac-blue); + color: var(--color-zodiac-blue); + + &.primary { + background-color: var(--color-ink-blue); + + &:global(.dark) { + color: var(--color-zodiac-blue); + } + } +} diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js new file mode 100644 index 0000000000..65b357df11 --- /dev/null +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { withTranslation } from 'react-i18next'; +import PropTypes from 'prop-types'; +import { useTheme } from '@utils/theme'; +import FlashMessage from '@toolbox/flashMessage/flashMessage'; +import { SecondaryButton } from '@toolbox/buttons'; +import Icon from '@toolbox/icon'; +import styles from './warnPunishedDelegate.css'; + +const WarnPunishedDelegate = ({ + t, readMore, message, ...props +}) => { + const theme = useTheme(); + + return ( + + +
+ + {message} +
+ + {t('Read more')} + +
+
+
+
+ ); +}; + +WarnPunishedDelegate.propTypes = { + message: PropTypes.string.isRequired, + readMore: PropTypes.func.isRequired, +}; + +export default withTranslation()(WarnPunishedDelegate); From c25abf55aa21ef3fe548619d1d489fc76d42d485 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Tue, 19 Oct 2021 15:09:40 +0100 Subject: [PATCH 04/34] :zap: Fetch and display punishment details on Warning --- src/components/screens/wallet/index.js | 4 +- .../screens/wallet/overview/index.js | 48 ++++++++++++++----- .../warnPunishedDelegate.js | 33 +++++++++++-- src/store/middlewares/block.js | 2 +- 4 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/components/screens/wallet/index.js b/src/components/screens/wallet/index.js index 84d9ecbb40..630ef4342e 100644 --- a/src/components/screens/wallet/index.js +++ b/src/components/screens/wallet/index.js @@ -2,8 +2,10 @@ import React, { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { withTranslation } from 'react-i18next'; +import { compose } from 'redux'; import { parseSearchParams, addSearchParamsToUrl } from '@utils/searchParams'; +import { withRouter } from 'react-router'; import { transactionsRetrieved } from '@actions'; import { selectAccount, @@ -93,4 +95,4 @@ const Wallet = ({ t, history }) => { ); }; -export default withTranslation()(Wallet); +export default compose(withRouter, withTranslation())(Wallet); diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index e67a925b86..df11800d64 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -1,3 +1,4 @@ +/* eslint-disable max-statements */ import React, { useEffect } from 'react'; import { useSelector } from 'react-redux'; import { compose } from 'redux'; @@ -9,6 +10,7 @@ import { getTransactions } from '@api/transaction'; import { selectTransactions } from '@store/selectors'; import FlashMessageHolder from '@toolbox/flashMessage/holder'; import WarnPunishedDelegate from '@shared/warnPunishedDelegate/warnPunishedDelegate'; +import { withRouter } from 'react-router'; import BalanceChart from './balanceChart'; import AccountInfo from './accountInfo'; import BalanceInfo from './balanceInfo'; @@ -22,6 +24,7 @@ const Overview = ({ discreetMode, isWalletRoute, account, + history, }) => { const { address, @@ -42,27 +45,47 @@ const Overview = ({ || '', ); - useEffect(() => { - if (!isWalletRoute && address) { - transactions.loadData({ address }); - } - }, [address]); - const readMore = () => { addSearchParamsToUrl({ modal: 'readMore' }); }; - return ( -
- { + const isBanned = account?.dpos?.delegate?.isBanned; + + const pomHeights = account?.dpos?.delegate?.pomHeights; + + const showWarning = () => { + if (!isWalletRoute && address && (isBanned || pomHeights?.length)) { FlashMessageHolder.addMessage( , 'WarnPunishedDelegate', - ) + ); + } else { + FlashMessageHolder.deleteMessage('WarnPunishedDelegate'); } + }; + + useEffect(() => { + const params = history?.location.search; + if (params === '') { + FlashMessageHolder.deleteMessage('WarnPunishedDelegate'); + } + }, []); + + useEffect(() => { + if (!isWalletRoute && address) { + transactions.loadData({ address }); + } + }, [address]); + + return ( +
+ { + showWarning() + }
@@ -90,7 +113,7 @@ const Overview = ({ isWalletRoute={isWalletRoute} username={account?.dpos?.delegate?.username} address={address} - isBanned={account?.dpos?.delegate?.isBanned} + isBanned={isBanned} />
diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 65b357df11..79e0bf7e8d 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -1,4 +1,5 @@ import React from 'react'; +import moment from 'moment'; import { withTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import { useTheme } from '@utils/theme'; @@ -8,16 +9,42 @@ import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; const WarnPunishedDelegate = ({ - t, readMore, message, ...props + t, + readMore, + isBanned, + pomHeights, + ...props }) => { const theme = useTheme(); + const getPunishmentDetails = (punishedHeights, punishedTimestamp) => { + const { start, end } = punishedHeights && punishedHeights[punishedHeights.length - 1]; + const startDate = new Date(punishedTimestamp * 1000); + const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); + // 10: block slot interval, 60: minutes, 24: hours + const numOfBlockPerDay = 10 * 60 * 24; + const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); + + return { daysLeft, punishmentStartDate }; + }; + + const { daysLeft, punishmentStartDate } = getPunishmentDetails(pomHeights, 1629632440); + + const message = isBanned + ? 'This delegate has been permanently banned from MM.DD.YYYY' + : `Caution! This delegate has been punished for ${daysLeft} days starting from ${punishmentStartDate}`; + return ( - +
- {message} + {`${message}`}
{ const now = new Date(); if (activeToken === tokenMap.LSK.key - && block.data[0].height !== blocks.latestBlocks[0].height) { + && block.data[0]?.height !== blocks.latestBlocks[0]?.height) { dispatch({ type: actionTypes.newBlockCreated, data: { From d022d7dfbb9e93d1fec2f9c4a215dfe94dedad34 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Wed, 20 Oct 2021 12:43:35 +0100 Subject: [PATCH 05/34] :zap: Add proper values and format for warning information --- jest.config.js | 1 + .../overview/balanceInfo/balanceInfo.css | 14 ++++----- .../wallet/overview/balanceInfo/index.js | 7 +++-- .../screens/wallet/overview/index.js | 2 +- .../shared/warnPunishedDelegate/index.js | 30 +++++++++++++++++++ .../warnPunishedDelegate.js | 23 ++++++++++---- 6 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 src/components/shared/warnPunishedDelegate/index.js diff --git a/jest.config.js b/jest.config.js index a8aa0f0ba1..ed7a512962 100644 --- a/jest.config.js +++ b/jest.config.js @@ -91,6 +91,7 @@ module.exports = { 'src/components/shared/searchBar/transactions.js', 'src/components/shared/navigationBars/topBar/networkName.js', 'src/components/shared/multisignatureMembers/index.js', + 'src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js', 'src/components/toolbox/tabsContainer/tabsContainer.js', 'src/components/toolbox/copyToClipboard/index.js', 'src/components/toolbox/dropdown/toolBoxDropdown.js', diff --git a/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css b/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css index f2c52d17ce..a9231a854c 100644 --- a/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css +++ b/src/components/screens/wallet/overview/balanceInfo/balanceInfo.css @@ -84,13 +84,6 @@ } } - & .voteButton:disabled { - cursor: not-allowed; - opacity: 0.5; - color: gray; - font-weight: 100; - } - & .sendButton { &.LSK { background-color: var(--color-ultramarine-blue); @@ -116,3 +109,10 @@ margin-right: 8px; } } + +.disabled { + cursor: not-allowed; + opacity: 0.5; + color: gray; + font-weight: 100; +} diff --git a/src/components/screens/wallet/overview/balanceInfo/index.js b/src/components/screens/wallet/overview/balanceInfo/index.js index a78d10dfe7..53ad0316bb 100644 --- a/src/components/screens/wallet/overview/balanceInfo/index.js +++ b/src/components/screens/wallet/overview/balanceInfo/index.js @@ -16,6 +16,7 @@ import SignInTooltipWrapper from '@shared/signInTooltipWrapper'; import LockedBalanceLink from './unlocking'; import styles from './balanceInfo.css'; +// eslint-disable-next-line complexity const BalanceInfo = ({ t, activeToken, @@ -60,7 +61,7 @@ const BalanceInfo = ({
{username ? ( {voteButtonTitle} diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index df11800d64..2bd7fdc279 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -9,7 +9,7 @@ import { addSearchParamsToUrl } from '@utils/searchParams'; import { getTransactions } from '@api/transaction'; import { selectTransactions } from '@store/selectors'; import FlashMessageHolder from '@toolbox/flashMessage/holder'; -import WarnPunishedDelegate from '@shared/warnPunishedDelegate/warnPunishedDelegate'; +import WarnPunishedDelegate from '@shared/warnPunishedDelegate'; import { withRouter } from 'react-router'; import BalanceChart from './balanceChart'; import AccountInfo from './accountInfo'; diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js new file mode 100644 index 0000000000..8dd2314fd1 --- /dev/null +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -0,0 +1,30 @@ +import { compose } from 'redux'; +import { connect } from 'react-redux'; +import { withRouter } from 'react-router-dom'; +import { getBlock } from '@api/block'; +import withData from '@utils/withData'; +import { withTranslation } from 'react-i18next'; +import WarnPunishedDelegate from './warnPunishedDelegate'; + +const mapStateToProps = (_, ownProps) => ({ + isBanned: ownProps.isBanned, + readMore: ownProps.readMore, + pomHeights: ownProps.pomHeights, +}); + +const apis = { + timestamp: { + apiUtil: (network, params) => getBlock({ network, params }), + getApiParams: (_, ownProps) => ({ + height: ownProps.pomHeights[ownProps.pomHeights.length - 1]?.start, + }), + transformResponse: response => (response.data && response.data[0]), + }, +}; + +export default compose( + withRouter, + connect(mapStateToProps), + withData(apis), + withTranslation(), +)(WarnPunishedDelegate); diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 79e0bf7e8d..ce932c5344 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import moment from 'moment'; import { withTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; @@ -13,12 +13,19 @@ const WarnPunishedDelegate = ({ readMore, isBanned, pomHeights, + startHeight, + endHeight, + timestamp, ...props }) => { const theme = useTheme(); - const getPunishmentDetails = (punishedHeights, punishedTimestamp) => { - const { start, end } = punishedHeights && punishedHeights[punishedHeights.length - 1]; + useEffect(() => { + timestamp.loadData(); + }, []); + + const getPunishmentDetails = (punishedTimestamp) => { + const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; const startDate = new Date(punishedTimestamp * 1000); const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); // 10: block slot interval, 60: minutes, 24: hours @@ -28,11 +35,15 @@ const WarnPunishedDelegate = ({ return { daysLeft, punishmentStartDate }; }; - const { daysLeft, punishmentStartDate } = getPunishmentDetails(pomHeights, 1629632440); + const { daysLeft, punishmentStartDate } = getPunishmentDetails( + timestamp.data.timestamp, + ); const message = isBanned - ? 'This delegate has been permanently banned from MM.DD.YYYY' - : `Caution! This delegate has been punished for ${daysLeft} days starting from ${punishmentStartDate}`; + ? `This delegate has been permanently banned from ${punishmentStartDate && punishmentStartDate}` + : `Caution! This delegate has been punished for ${ + daysLeft && daysLeft + } days starting from ${punishmentStartDate && punishmentStartDate}`; return ( Date: Wed, 20 Oct 2021 12:46:40 +0100 Subject: [PATCH 06/34] merge development --- i18n/locales/en/common.json | 1 + 1 file changed, 1 insertion(+) diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index f9f8d7adb4..729cb94c64 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -479,6 +479,7 @@ "The transaction was broadcasted to the network. It will appear in sender account's wallet after confirmation.": "The transaction was broadcasted to the network. It will appear in sender account's wallet after confirmation.", "The ultimate gateway to the ecosystem. Lisk’s new design lets you easily manage your LSK (and much, much more).": "The ultimate gateway to the ecosystem. Lisk’s new design lets you easily manage your LSK (and much, much more).", "The updated amount after voting": "The updated amount after voting", + "The vote amount is too high. You should keep at least 0.05 LSK available in your account.": "The vote amount is too high. You should keep at least 0.05 LSK available in your account.", "The {{inputLabel}} can't be empty": "The {{inputLabel}} can't be empty", "There are no results matching your search term.": "There are no results matching your search term.", "There are no transactions for this block.": "There are no transactions for this block.", From 986d30856706559d30ab3c8814f61ae1f2d6e9fd Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 21 Oct 2021 15:25:00 +0200 Subject: [PATCH 07/34] Move message generator function & Use string interpolation --- i18n/locales/en/common.json | 2 + .../warnPunishedDelegate.js | 47 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index 729cb94c64..6071e2a5ba 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -71,6 +71,7 @@ "By voting you decide who is trusted to verify transactions and maintain the Lisk network, whilst collecting the rewards for doing so.": "By voting you decide who is trusted to verify transactions and maintain the Lisk network, whilst collecting the rewards for doing so.", "Bytes counter": "Bytes counter", "Cancel": "Cancel", + "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}": "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}", "Changed votes": "Changed votes", "Check for Updates...": "Check for Updates...", "Choose your avatar": "Choose your avatar", @@ -493,6 +494,7 @@ "This account doesn’t have any votes.": "This account doesn’t have any votes.", "This account requires {{numberOfSignatures}} signatures to create a valid transaction.": "This account requires {{numberOfSignatures}} signatures to create a valid transaction.", "This avatar will be linked to your new Lisk address.": "This avatar will be linked to your new Lisk address.", + "This delegate has been permanently banned from {{punishmentStartDate}}": "This delegate has been permanently banned from {{punishmentStartDate}}", "This delegate will be punished in upcoming rounds": "This delegate will be punished in upcoming rounds", "This helps to keep the network fair, open and honest.": "This helps to keep the network fair, open and honest.", "This is a legacy account and can not be used on this network.": "This is a legacy account and can not be used on this network.", diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index ce932c5344..23eb471309 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -8,6 +8,30 @@ import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; +const getPunishmentDetails = (punishedTimestamp, pomHeights) => { + const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; + const startDate = new Date(punishedTimestamp * 1000); + const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); + // 10: block slot interval, 60: minutes, 24: hours + const numOfBlockPerDay = 10 * 60 * 24; + const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); + + return { daysLeft, punishmentStartDate }; +}; + +const getMessage = ({ + isBanned, pomHeights, timestamp, t, +}) => { + const { daysLeft, punishmentStartDate } = getPunishmentDetails( + timestamp.data.timestamp, + pomHeights, + ); + + return isBanned + ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) + : t('Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}', { daysLeft, punishmentStartDate }) +}; + const WarnPunishedDelegate = ({ t, readMore, @@ -24,26 +48,9 @@ const WarnPunishedDelegate = ({ timestamp.loadData(); }, []); - const getPunishmentDetails = (punishedTimestamp) => { - const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; - const startDate = new Date(punishedTimestamp * 1000); - const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); - // 10: block slot interval, 60: minutes, 24: hours - const numOfBlockPerDay = 10 * 60 * 24; - const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); - - return { daysLeft, punishmentStartDate }; - }; - - const { daysLeft, punishmentStartDate } = getPunishmentDetails( - timestamp.data.timestamp, - ); - - const message = isBanned - ? `This delegate has been permanently banned from ${punishmentStartDate && punishmentStartDate}` - : `Caution! This delegate has been punished for ${ - daysLeft && daysLeft - } days starting from ${punishmentStartDate && punishmentStartDate}`; + const message = getMessage({ + isBanned, pomHeights, timestamp, t, + }); return ( Date: Thu, 21 Oct 2021 16:02:32 +0200 Subject: [PATCH 08/34] Add warning message to EditVote --- i18n/locales/en/common.json | 1 + src/components/screens/editVote/editVote.css | 11 +++++ src/components/screens/editVote/index.js | 43 ++++++++++++++++--- .../screens/wallet/overview/index.js | 1 - 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index 6071e2a5ba..2e46710161 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -72,6 +72,7 @@ "Bytes counter": "Bytes counter", "Cancel": "Cancel", "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}": "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}", + "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of XX days. In addition, please note that your vote will not be counted until the XX day period has expired.": "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of XX days. In addition, please note that your vote will not be counted until the XX day period has expired.", "Changed votes": "Changed votes", "Check for Updates...": "Check for Updates...", "Choose your avatar": "Choose your avatar", diff --git a/src/components/screens/editVote/editVote.css b/src/components/screens/editVote/editVote.css index 928714151e..00e97b4abd 100644 --- a/src/components/screens/editVote/editVote.css +++ b/src/components/screens/editVote/editVote.css @@ -63,3 +63,14 @@ width: 100%; } } + +.warningContainer { + background-color: var(--color-warning-bg); + border: solid 1px var(--color-warning-border); + border-radius: 5px; + display: flex; + align-items: flex-start; + font-size: 18px; + padding: 10px; + margin-top: 10px; +} diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 529245458b..1fea51ce59 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -1,8 +1,10 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { withRouter } from 'react-router-dom'; import { withTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; - +import { compose } from 'redux'; +import withData from '@utils/withData'; +import { getAccount } from '@api/account'; import { selectSearchParamValue, removeSearchParamsFromUrl } from '@utils/searchParams'; import { tokenMap } from '@constants'; import { voteEdited } from '@actions'; @@ -18,10 +20,18 @@ import AmountField from '@shared/amountField'; import LiskAmount from '@shared/liskAmount'; import Converter from '@shared/converter'; import { PrimaryButton, WarningButton } from '@toolbox/buttons'; +import Icon from '@toolbox/icon'; import useVoteAmountField from './useVoteAmountField'; import styles from './editVote.css'; +const WarningMessage = ({ t }) => ( +
+ + {t('Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of XX days. In addition, please note that your vote will not be counted until the XX day period has expired.')} +
+); + const getTitles = t => ({ edit: { title: t('Edit vote'), @@ -35,17 +45,21 @@ const getTitles = t => ({ // eslint-disable-next-line max-statements const AddVote = ({ - history, t, + history, t, account, }) => { const dispatch = useDispatch(); const host = useSelector(state => state.account.info.LSK.summary.address); const address = selectSearchParamValue(history.location.search, 'address'); + const pomHeights = account.data.dpos?.delegate?.pomHeights; const existingVote = useSelector(state => state.voting[address || host]); - const activeToken = tokenMap.LSK.key; const balance = useSelector(selectAccountBalance); const [voteAmount, setVoteAmount] = useVoteAmountField(existingVote ? fromRawLsk(existingVote.unconfirmed) : '', balance); const mode = existingVote ? 'edit' : 'add'; + useEffect(() => { + account.loadData(); + }, [address]); + const confirm = () => { dispatch(voteEdited([{ address: address || host, @@ -68,6 +82,7 @@ const AddVote = ({ return ( + {pomHeights?.length && }

{titles.title}

@@ -80,7 +95,7 @@ const AddVote = ({

Available balance

- + getAccount({ network, params }, token), + getApiParams: (state, props) => ({ + token: tokenMap.LSK.key, + address: selectSearchParamValue(props.history.location.search, 'address'), + network: state.network, + }), + transformResponse: response => response, + }, +}; + +export default compose( + withRouter, + withData(apis), + withTranslation(), +)(AddVote); diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 2bd7fdc279..c7923a7329 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -50,7 +50,6 @@ const Overview = ({ }; const isBanned = account?.dpos?.delegate?.isBanned; - const pomHeights = account?.dpos?.delegate?.pomHeights; const showWarning = () => { From 97905c6b0215a77a6d870aae43ad0d9c62713242 Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 21 Oct 2021 16:19:12 +0200 Subject: [PATCH 09/34] Create add/remove warning functions --- .../screens/wallet/overview/index.js | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index c7923a7329..8e79b44efe 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -16,6 +16,21 @@ import AccountInfo from './accountInfo'; import BalanceInfo from './balanceInfo'; import styles from './overview.css'; +const addWarningMessage = ({ isBanned, pomHeights, readMore }) => { + FlashMessageHolder.addMessage( + , + 'WarnPunishedDelegate', + ); +}; + +const removeWarningMessage = () => { + FlashMessageHolder.deleteMessage('WarnPunishedDelegate'); +}; + const Overview = ({ t, activeToken, @@ -32,10 +47,12 @@ const Overview = ({ balance = 0, isMultisignature, } = account?.summary ?? {}; + const isBanned = account?.dpos?.delegate?.isBanned; + const pomHeights = account?.dpos?.delegate?.pomHeights; + const { confirmed } = useSelector(selectTransactions); const bookmark = useSelector((state) => state.bookmarks[activeToken].find((item) => item.address === address)); - const host = useSelector( (state) => (state.account @@ -45,32 +62,24 @@ const Overview = ({ || '', ); - const readMore = () => { - addSearchParamsToUrl({ modal: 'readMore' }); - }; - - const isBanned = account?.dpos?.delegate?.isBanned; - const pomHeights = account?.dpos?.delegate?.pomHeights; - const showWarning = () => { if (!isWalletRoute && address && (isBanned || pomHeights?.length)) { - FlashMessageHolder.addMessage( - , - 'WarnPunishedDelegate', - ); + addWarningMessage({ + isBanned, + pomHeights, + readMore: () => { + // TODO open blog entry + }, + }); } else { - FlashMessageHolder.deleteMessage('WarnPunishedDelegate'); + removeWarningMessage(); } }; useEffect(() => { const params = history?.location.search; if (params === '') { - FlashMessageHolder.deleteMessage('WarnPunishedDelegate'); + removeWarningMessage(); } }, []); From f27371cfe8ce05fdf8aee8fd09f4ab47dfff8a04 Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 21 Oct 2021 17:03:56 +0200 Subject: [PATCH 10/34] Disable warning when loggout --- src/components/screens/wallet/overview/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 8e79b44efe..372f6f1305 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -5,7 +5,6 @@ import { compose } from 'redux'; import { withTranslation } from 'react-i18next'; import grid from 'flexboxgrid/dist/flexboxgrid.css'; import withData from '@utils/withData'; -import { addSearchParamsToUrl } from '@utils/searchParams'; import { getTransactions } from '@api/transaction'; import { selectTransactions } from '@store/selectors'; import FlashMessageHolder from '@toolbox/flashMessage/holder'; @@ -63,7 +62,7 @@ const Overview = ({ ); const showWarning = () => { - if (!isWalletRoute && address && (isBanned || pomHeights?.length)) { + if (!isWalletRoute && host && address && (isBanned || pomHeights?.length)) { addWarningMessage({ isBanned, pomHeights, From bd3376cf8819adf3a2442bf0f1b38713e9081bce Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 21 Oct 2021 17:15:43 +0200 Subject: [PATCH 11/34] Remove message on navigate out of /account --- .../warnPunishedDelegate/warnPunishedDelegate.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 23eb471309..c33bd2007f 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -2,8 +2,10 @@ import React, { useEffect } from 'react'; import moment from 'moment'; import { withTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; +import { routes } from '@constants'; import { useTheme } from '@utils/theme'; import FlashMessage from '@toolbox/flashMessage/flashMessage'; +import FlashMessageHolder from '@toolbox/flashMessage/holder'; import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; @@ -34,12 +36,10 @@ const getMessage = ({ const WarnPunishedDelegate = ({ t, - readMore, isBanned, pomHeights, - startHeight, - endHeight, timestamp, + history, ...props }) => { const theme = useTheme(); @@ -48,6 +48,12 @@ const WarnPunishedDelegate = ({ timestamp.loadData(); }, []); + useEffect(() => { + if (history.location.pathname !== routes.account.path) { + FlashMessageHolder.deleteMessage('WarnPunishedDelegate'); + } + }, [history.location.pathname]); + const message = getMessage({ isBanned, pomHeights, timestamp, t, }); From c0f14f41c505c7ca8379a1d69bd4cee1cc18c5db Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 21 Oct 2021 17:29:49 +0200 Subject: [PATCH 12/34] Calculate days left for vote to be counted --- i18n/locales/en/common.json | 2 +- src/components/screens/editVote/index.js | 55 ++++++++++++++++--- .../warnPunishedDelegate.js | 1 + 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index 2e46710161..ac0e2c0622 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -72,7 +72,7 @@ "Bytes counter": "Bytes counter", "Cancel": "Cancel", "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}": "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}", - "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of XX days. In addition, please note that your vote will not be counted until the XX day period has expired.": "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of XX days. In addition, please note that your vote will not be counted until the XX day period has expired.", + "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.": "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.", "Changed votes": "Changed votes", "Check for Updates...": "Check for Updates...", "Choose your avatar": "Choose your avatar", diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 1fea51ce59..329a29e3ed 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -3,6 +3,7 @@ import { withRouter } from 'react-router-dom'; import { withTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; import { compose } from 'redux'; +import moment from 'moment'; import withData from '@utils/withData'; import { getAccount } from '@api/account'; import { selectSearchParamValue, removeSearchParamsFromUrl } from '@utils/searchParams'; @@ -21,16 +22,42 @@ import LiskAmount from '@shared/liskAmount'; import Converter from '@shared/converter'; import { PrimaryButton, WarningButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; +import { getBlock } from '@api/block'; import useVoteAmountField from './useVoteAmountField'; import styles from './editVote.css'; -const WarningMessage = ({ t }) => ( -
- - {t('Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of XX days. In addition, please note that your vote will not be counted until the XX day period has expired.')} -
-); +// TODO move this calculation to utils +const getPunishmentDetails = (punishedTimestamp, pomHeights) => { + const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; + const startDate = new Date(punishedTimestamp * 1000); + const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); + // 10: block slot interval, 60: minutes, 24: hours + const numOfBlockPerDay = 10 * 60 * 24; + const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); + + return { daysLeft, punishmentStartDate }; +}; + +const WarningMessage = ({ t, pomHeights, timestamp }) => { + const { daysLeft } = getPunishmentDetails( + timestamp.data.timestamp, + pomHeights, + ); + + return ( +
+ + {t( + 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', + { + lockedTime: 'XX', + daysLeft, + }, + )} +
+ ); +}; const getTitles = t => ({ edit: { @@ -45,7 +72,7 @@ const getTitles = t => ({ // eslint-disable-next-line max-statements const AddVote = ({ - history, t, account, + history, t, account, timestamp, }) => { const dispatch = useDispatch(); const host = useSelector(state => state.account.info.LSK.summary.address); @@ -60,6 +87,14 @@ const AddVote = ({ account.loadData(); }, [address]); + useEffect(() => { + if (pomHeights?.length) { + timestamp.loadData({ + height: pomHeights[pomHeights.length - 1]?.start, + }); + } + }, [pomHeights]); + const confirm = () => { dispatch(voteEdited([{ address: address || host, @@ -82,7 +117,7 @@ const AddVote = ({ return ( - {pomHeights?.length && } + {pomHeights?.length && }

{titles.title}

@@ -142,6 +177,10 @@ const apis = { }), transformResponse: response => response, }, + timestamp: { + apiUtil: (network, params) => getBlock({ network, params }), + transformResponse: response => (response.data && response.data[0]), + }, }; export default compose( diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index c33bd2007f..10f326da61 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -10,6 +10,7 @@ import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; +// TODO move this calculation to utils const getPunishmentDetails = (punishedTimestamp, pomHeights) => { const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; const startDate = new Date(punishedTimestamp * 1000); From b1126ad63a92116e5e38d4f5aaa8654d0eb8eb40 Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 21 Oct 2021 17:33:50 +0200 Subject: [PATCH 13/34] Open window on ReadMore clock --- src/components/screens/wallet/overview/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 372f6f1305..12b8e50af3 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -67,7 +67,9 @@ const Overview = ({ isBanned, pomHeights, readMore: () => { - // TODO open blog entry + // TODO define blog entry url + const url = ''; + window.open(url, '_blank', 'rel="noopener noreferrer'); }, }); } else { From b12f9f424685dd5d01c68dfe784ea4431d4fc1ce Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Fri, 22 Oct 2021 12:00:21 +0200 Subject: [PATCH 14/34] Move edit vote warning to shared component --- src/components/screens/editVote/editVote.css | 11 ------ src/components/screens/editVote/index.js | 39 ++----------------- .../warnPunishedDelegate.css | 11 ++++++ .../warnPunishedDelegate.js | 39 ++++++++++++------- 4 files changed, 41 insertions(+), 59 deletions(-) diff --git a/src/components/screens/editVote/editVote.css b/src/components/screens/editVote/editVote.css index 00e97b4abd..928714151e 100644 --- a/src/components/screens/editVote/editVote.css +++ b/src/components/screens/editVote/editVote.css @@ -63,14 +63,3 @@ width: 100%; } } - -.warningContainer { - background-color: var(--color-warning-bg); - border: solid 1px var(--color-warning-border); - border-radius: 5px; - display: flex; - align-items: flex-start; - font-size: 18px; - padding: 10px; - margin-top: 10px; -} diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 329a29e3ed..3a61b4f62d 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -3,7 +3,6 @@ import { withRouter } from 'react-router-dom'; import { withTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; import { compose } from 'redux'; -import moment from 'moment'; import withData from '@utils/withData'; import { getAccount } from '@api/account'; import { selectSearchParamValue, removeSearchParamsFromUrl } from '@utils/searchParams'; @@ -20,45 +19,13 @@ import BoxInfoText from '@toolbox/box/infoText'; import AmountField from '@shared/amountField'; import LiskAmount from '@shared/liskAmount'; import Converter from '@shared/converter'; +import WarnPunishedDelegate from '@shared/warnPunishedDelegate'; import { PrimaryButton, WarningButton } from '@toolbox/buttons'; -import Icon from '@toolbox/icon'; import { getBlock } from '@api/block'; import useVoteAmountField from './useVoteAmountField'; import styles from './editVote.css'; -// TODO move this calculation to utils -const getPunishmentDetails = (punishedTimestamp, pomHeights) => { - const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; - const startDate = new Date(punishedTimestamp * 1000); - const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); - // 10: block slot interval, 60: minutes, 24: hours - const numOfBlockPerDay = 10 * 60 * 24; - const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); - - return { daysLeft, punishmentStartDate }; -}; - -const WarningMessage = ({ t, pomHeights, timestamp }) => { - const { daysLeft } = getPunishmentDetails( - timestamp.data.timestamp, - pomHeights, - ); - - return ( -
- - {t( - 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', - { - lockedTime: 'XX', - daysLeft, - }, - )} -
- ); -}; - const getTitles = t => ({ edit: { title: t('Edit vote'), @@ -117,7 +84,9 @@ const AddVote = ({ return ( - {pomHeights?.length && } + {pomHeights?.length && ( + + )}

{titles.title}

diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css index 452d6c69fc..36ebd3912c 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css @@ -33,3 +33,14 @@ } } } + +.editVoteContainer { + background-color: var(--color-warning-bg); + border: solid 1px var(--color-warning-border); + border-radius: 5px; + display: flex; + align-items: flex-start; + font-size: 18px; + padding: 10px; + margin-top: 10px; +} diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 10f326da61..9607eb8d99 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -10,7 +10,6 @@ import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; -// TODO move this calculation to utils const getPunishmentDetails = (punishedTimestamp, pomHeights) => { const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; const startDate = new Date(punishedTimestamp * 1000); @@ -23,17 +22,11 @@ const getPunishmentDetails = (punishedTimestamp, pomHeights) => { }; const getMessage = ({ - isBanned, pomHeights, timestamp, t, -}) => { - const { daysLeft, punishmentStartDate } = getPunishmentDetails( - timestamp.data.timestamp, - pomHeights, - ); - - return isBanned - ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) - : t('Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}', { daysLeft, punishmentStartDate }) -}; + isBanned, daysLeft, punishmentStartDate, t, +}) => (isBanned + ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) + : t('Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}', { daysLeft, punishmentStartDate }) +); const WarnPunishedDelegate = ({ t, @@ -41,9 +34,14 @@ const WarnPunishedDelegate = ({ pomHeights, timestamp, history, + editVote, ...props }) => { const theme = useTheme(); + const { daysLeft, punishmentStartDate } = getPunishmentDetails( + timestamp.data.timestamp, + pomHeights, + ); useEffect(() => { timestamp.loadData(); @@ -56,9 +54,24 @@ const WarnPunishedDelegate = ({ }, [history.location.pathname]); const message = getMessage({ - isBanned, pomHeights, timestamp, t, + isBanned, daysLeft, punishmentStartDate, t, }); + if (editVote) { + return ( +
+ + {t( + 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', + { + lockedTime: 'XX', + daysLeft, + }, + )} +
+ ); + } + return ( Date: Fri, 22 Oct 2021 12:18:51 +0200 Subject: [PATCH 15/34] Decouple WarnPunishedDelegate component --- src/components/screens/editVote/index.js | 2 +- .../shared/warnPunishedDelegate/index.js | 45 +++++++++++++--- .../warnPunishedDelegate/voteWarning.js | 19 +++++++ .../warnPunishedDelegate.css | 2 +- .../warnPunishedDelegate.js | 53 ++----------------- 5 files changed, 63 insertions(+), 58 deletions(-) create mode 100644 src/components/shared/warnPunishedDelegate/voteWarning.js diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 3a61b4f62d..4af885f53c 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -85,7 +85,7 @@ const AddVote = ({ return ( {pomHeights?.length && ( - + )} diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 8dd2314fd1..859371b28a 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -1,16 +1,46 @@ +import React, { useEffect } from 'react'; import { compose } from 'redux'; -import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; +import moment from 'moment'; import { getBlock } from '@api/block'; import withData from '@utils/withData'; import { withTranslation } from 'react-i18next'; +import VoteWarning from './voteWarning'; import WarnPunishedDelegate from './warnPunishedDelegate'; -const mapStateToProps = (_, ownProps) => ({ - isBanned: ownProps.isBanned, - readMore: ownProps.readMore, - pomHeights: ownProps.pomHeights, -}); +const getPunishmentDetails = (punishedTimestamp, pomHeights) => { + const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; + const startDate = new Date(punishedTimestamp * 1000); + const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); + // 10: block slot interval, 60: minutes, 24: hours + const numOfBlockPerDay = 10 * 60 * 24; + const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); + + return { daysLeft, punishmentStartDate }; +}; + +const Warning = ({ vote, ...props }) => { + useEffect(() => { + props.timestamp.loadData(); + }, []); + + const { daysLeft, punishmentStartDate } = getPunishmentDetails( + props.timestamp.data.timestamp, + props.pomHeights, + ); + + if (vote) { + return ; + } + + return ( + + ); +}; const apis = { timestamp: { @@ -24,7 +54,6 @@ const apis = { export default compose( withRouter, - connect(mapStateToProps), withData(apis), withTranslation(), -)(WarnPunishedDelegate); +)(Warning); diff --git a/src/components/shared/warnPunishedDelegate/voteWarning.js b/src/components/shared/warnPunishedDelegate/voteWarning.js new file mode 100644 index 0000000000..b67640add7 --- /dev/null +++ b/src/components/shared/warnPunishedDelegate/voteWarning.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { withTranslation } from 'react-i18next'; +import Icon from '@toolbox/icon'; +import styles from './warnPunishedDelegate.css'; + +const VoteWarning = ({ t, daysLeft }) => ( +
+ + {t( + 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', + { + lockedTime: 'XX', + daysLeft, + }, + )} +
+); + +export default withTranslation()(VoteWarning); diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css index 36ebd3912c..8cddd32b48 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css @@ -34,7 +34,7 @@ } } -.editVoteContainer { +.voteContainer { background-color: var(--color-warning-bg); border: solid 1px var(--color-warning-border); border-radius: 5px; diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 9607eb8d99..931e46e567 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -1,5 +1,4 @@ import React, { useEffect } from 'react'; -import moment from 'moment'; import { withTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import { routes } from '@constants'; @@ -10,42 +9,15 @@ import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; -const getPunishmentDetails = (punishedTimestamp, pomHeights) => { - const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; - const startDate = new Date(punishedTimestamp * 1000); - const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); - // 10: block slot interval, 60: minutes, 24: hours - const numOfBlockPerDay = 10 * 60 * 24; - const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); - - return { daysLeft, punishmentStartDate }; -}; - -const getMessage = ({ - isBanned, daysLeft, punishmentStartDate, t, -}) => (isBanned - ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) - : t('Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}', { daysLeft, punishmentStartDate }) -); - const WarnPunishedDelegate = ({ t, isBanned, - pomHeights, - timestamp, history, - editVote, + daysLeft, + punishmentStartDate, ...props }) => { const theme = useTheme(); - const { daysLeft, punishmentStartDate } = getPunishmentDetails( - timestamp.data.timestamp, - pomHeights, - ); - - useEffect(() => { - timestamp.loadData(); - }, []); useEffect(() => { if (history.location.pathname !== routes.account.path) { @@ -53,24 +25,9 @@ const WarnPunishedDelegate = ({ } }, [history.location.pathname]); - const message = getMessage({ - isBanned, daysLeft, punishmentStartDate, t, - }); - - if (editVote) { - return ( -
- - {t( - 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', - { - lockedTime: 'XX', - daysLeft, - }, - )} -
- ); - } + const message = isBanned + ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) + : t('Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}', { daysLeft, punishmentStartDate }); return ( Date: Fri, 22 Oct 2021 11:40:58 +0100 Subject: [PATCH 16/34] Fix delegate warning on dark mode --- .../shared/warnPunishedDelegate/warnPunishedDelegate.css | 4 ++++ .../shared/warnPunishedDelegate/warnPunishedDelegate.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css index 8cddd32b48..f33a7a0dac 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.css @@ -10,6 +10,10 @@ align-items: center; width: 100%; font-size: 18px; + + &:global(.dark) { + color: var(--color-zodiac-blue); + } } .btnContainer { diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 931e46e567..05d339be6e 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -37,7 +37,7 @@ const WarnPunishedDelegate = ({ className={styles.flashContainer} > -
+
{`${message}`}
From 242f3b10f98cc6ddf24c2bba95dd28cd47356bdd Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Mon, 25 Oct 2021 05:31:11 +0100 Subject: [PATCH 17/34] Update add vote warning text --- i18n/locales/en/common.json | 2 +- src/components/shared/warnPunishedDelegate/voteWarning.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index ac0e2c0622..ec4ef50071 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -72,7 +72,7 @@ "Bytes counter": "Bytes counter", "Cancel": "Cancel", "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}": "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}", - "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.": "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.", + "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{daysLeft}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.": "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{daysLeft}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.", "Changed votes": "Changed votes", "Check for Updates...": "Check for Updates...", "Choose your avatar": "Choose your avatar", diff --git a/src/components/shared/warnPunishedDelegate/voteWarning.js b/src/components/shared/warnPunishedDelegate/voteWarning.js index b67640add7..363a4f0785 100644 --- a/src/components/shared/warnPunishedDelegate/voteWarning.js +++ b/src/components/shared/warnPunishedDelegate/voteWarning.js @@ -7,9 +7,8 @@ const VoteWarning = ({ t, daysLeft }) => (
{t( - 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{lockedTime}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', + 'Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{daysLeft}} days. In addition, please note that your vote will not be counted until the {{daysLeft}} day period has expired.', { - lockedTime: 'XX', daysLeft, }, )} From d7c0df0e7cc519f964e273f67cd2d9d171902979 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Mon, 25 Oct 2021 05:47:21 +0100 Subject: [PATCH 18/34] Refactor editVote --- src/components/screens/editVote/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 4af885f53c..1d0a1cb219 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -84,7 +84,7 @@ const AddVote = ({ return ( - {pomHeights?.length && ( + {pomHeights?.length > 0 && ( )} From b43e621e323f19362bf96376a901d9a6d6f6e654 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Mon, 25 Oct 2021 06:13:22 +0100 Subject: [PATCH 19/34] Skip vote warning tests --- jest.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jest.config.js b/jest.config.js index 502744c0a8..3eef20e2c4 100644 --- a/jest.config.js +++ b/jest.config.js @@ -95,6 +95,8 @@ module.exports = { 'src/components/shared/navigationBars/topBar/networkName.js', 'src/components/shared/multisignatureMembers/index.js', 'src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js', + 'src/components/shared/warnPunishedDelegate/index.js', + 'src/components/shared/warnPunishedDelegate/voteWarning.js', 'src/components/toolbox/tabsContainer/tabsContainer.js', 'src/components/toolbox/copyToClipboard/index.js', 'src/components/toolbox/dropdown/toolBoxDropdown.js', From ec3bc7b483ed20a23bba75b6ee076193cfe782c7 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Mon, 25 Oct 2021 11:41:38 +0100 Subject: [PATCH 20/34] Apply suggestions from code review Co-authored-by: Manu --- src/components/screens/editVote/index.js | 8 ++++---- src/components/shared/warnPunishedDelegate/index.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 1d0a1cb219..cf5bdb7b57 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -39,7 +39,7 @@ const getTitles = t => ({ // eslint-disable-next-line max-statements const AddVote = ({ - history, t, account, timestamp, + history, t, account, block, }) => { const dispatch = useDispatch(); const host = useSelector(state => state.account.info.LSK.summary.address); @@ -56,7 +56,7 @@ const AddVote = ({ useEffect(() => { if (pomHeights?.length) { - timestamp.loadData({ + block.loadData({ height: pomHeights[pomHeights.length - 1]?.start, }); } @@ -85,7 +85,7 @@ const AddVote = ({ return ( {pomHeights?.length > 0 && ( - + )} @@ -146,7 +146,7 @@ const apis = { }), transformResponse: response => response, }, - timestamp: { + block: { apiUtil: (network, params) => getBlock({ network, params }), transformResponse: response => (response.data && response.data[0]), }, diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 859371b28a..385daf4647 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -21,11 +21,11 @@ const getPunishmentDetails = (punishedTimestamp, pomHeights) => { const Warning = ({ vote, ...props }) => { useEffect(() => { - props.timestamp.loadData(); + props.block.loadData(); }, []); const { daysLeft, punishmentStartDate } = getPunishmentDetails( - props.timestamp.data.timestamp, + props.block.data.timestamp, props.pomHeights, ); @@ -43,7 +43,7 @@ const Warning = ({ vote, ...props }) => { }; const apis = { - timestamp: { + block: { apiUtil: (network, params) => getBlock({ network, params }), getApiParams: (_, ownProps) => ({ height: ownProps.pomHeights[ownProps.pomHeights.length - 1]?.start, From c517c0ca095e7d79b6414310936fc4d9b9143125 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Mon, 25 Oct 2021 15:11:47 +0100 Subject: [PATCH 21/34] Fix daysLeft calculation logic --- .../shared/warnPunishedDelegate/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 385daf4647..850a3c7543 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -1,6 +1,7 @@ import React, { useEffect } from 'react'; import { compose } from 'redux'; import { withRouter } from 'react-router-dom'; +import { connect } from 'react-redux'; import moment from 'moment'; import { getBlock } from '@api/block'; import withData from '@utils/withData'; @@ -8,13 +9,17 @@ import { withTranslation } from 'react-i18next'; import VoteWarning from './voteWarning'; import WarnPunishedDelegate from './warnPunishedDelegate'; -const getPunishmentDetails = (punishedTimestamp, pomHeights) => { - const { start, end } = pomHeights && pomHeights[pomHeights.length - 1]; +const mapStateToProps = (state) => ({ + currentHeight: state.blocks.latestBlocks.length ? state.blocks.latestBlocks[0].height : 0, +}); + +const getPunishmentDetails = (punishedTimestamp, pomHeights, currentHeight) => { + const { end } = pomHeights && pomHeights[pomHeights.length - 1]; const startDate = new Date(punishedTimestamp * 1000); const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); - // 10: block slot interval, 60: minutes, 24: hours - const numOfBlockPerDay = 10 * 60 * 24; - const daysLeft = Math.ceil((end - start) / numOfBlockPerDay); + // 6: blocks per minute, 60: minutes, 24: hours + const numOfBlockPerDay = 24 * 60 * 6; + const daysLeft = Math.ceil((end - currentHeight) / numOfBlockPerDay); return { daysLeft, punishmentStartDate }; }; @@ -27,6 +32,7 @@ const Warning = ({ vote, ...props }) => { const { daysLeft, punishmentStartDate } = getPunishmentDetails( props.block.data.timestamp, props.pomHeights, + props.currentHeight, ); if (vote) { @@ -54,6 +60,7 @@ const apis = { export default compose( withRouter, + connect(mapStateToProps), withData(apis), withTranslation(), )(Warning); From 9b34286ca5781e1e84f37421744ce3db65b636aa Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Tue, 26 Oct 2021 14:56:20 +0100 Subject: [PATCH 22/34] Update warning message and disable readmore button --- i18n/locales/en/common.json | 2 +- .../shared/warnPunishedDelegate/warnPunishedDelegate.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index cc0e1c266c..bd138f45b1 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -71,7 +71,7 @@ "By voting you decide who is trusted to verify transactions and maintain the Lisk network, whilst collecting the rewards for doing so.": "By voting you decide who is trusted to verify transactions and maintain the Lisk network, whilst collecting the rewards for doing so.", "Bytes counter": "Bytes counter", "Cancel": "Cancel", - "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}": "Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}", + "Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.": "Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.", "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{daysLeft}} days.": "Caution! You are about to vote for the punished delegate, this will result in your LSK tokens being locked for a period of {{daysLeft}} days.", "Changed votes": "Changed votes", "Check for Updates...": "Check for Updates...", diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 05d339be6e..e9faf4bb3c 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -5,7 +5,7 @@ import { routes } from '@constants'; import { useTheme } from '@utils/theme'; import FlashMessage from '@toolbox/flashMessage/flashMessage'; import FlashMessageHolder from '@toolbox/flashMessage/holder'; -import { SecondaryButton } from '@toolbox/buttons'; +// import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; @@ -27,7 +27,7 @@ const WarnPunishedDelegate = ({ const message = isBanned ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) - : t('Caution! This delegate has been punished for {{daysLeft}} days starting from {{punishmentStartDate}}', { daysLeft, punishmentStartDate }); + : t('Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.', { punishmentStartDate, daysLeft }); return ( {`${message}`}
- {t('Read more')} - + */}
From dbe48d0305c24e3c3d1bf9772252c74246ff9d46 Mon Sep 17 00:00:00 2001 From: reyraa Date: Wed, 27 Oct 2021 10:51:23 +0200 Subject: [PATCH 23/34] Remove redundant API calls and hooks --- src/components/screens/editVote/index.js | 44 +++---------------- .../wallet/overview/balanceInfo/index.js | 6 +++ 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 2e4a37b5a9..2129b05954 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -1,10 +1,9 @@ -import React, { useEffect } from 'react'; -import { withRouter } from 'react-router-dom'; +import React from 'react'; import { withTranslation } from 'react-i18next'; +import { withRouter } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; import { compose } from 'redux'; -import withData from '@utils/withData'; -import { getAccount } from '@api/account'; + import { selectSearchParamValue, removeSearchParamsFromUrl } from '@utils/searchParams'; import { tokenMap } from '@constants'; import { voteEdited } from '@actions'; @@ -21,7 +20,6 @@ import LiskAmount from '@shared/liskAmount'; import Converter from '@shared/converter'; import WarnPunishedDelegate from '@shared/warnPunishedDelegate'; import { PrimaryButton, WarningButton } from '@toolbox/buttons'; -import { getBlock } from '@api/block'; import useVoteAmountField from './useVoteAmountField'; import styles from './editVote.css'; @@ -39,29 +37,16 @@ const getTitles = t => ({ // eslint-disable-next-line max-statements const AddVote = ({ - history, t, account, block, + history, t, start, end, }) => { const dispatch = useDispatch(); const host = useSelector(state => state.account.info.LSK.summary.address); const address = selectSearchParamValue(history.location.search, 'address'); - const pomHeights = account.data.dpos?.delegate?.pomHeights; const existingVote = useSelector(state => state.voting[address || host]); const balance = useSelector(selectAccountBalance); const [voteAmount, setVoteAmount] = useVoteAmountField(existingVote ? fromRawLsk(existingVote.unconfirmed) : '', balance); const mode = existingVote ? 'edit' : 'add'; - useEffect(() => { - account.loadData(); - }, [address]); - - useEffect(() => { - if (pomHeights?.length) { - block.loadData({ - height: pomHeights[pomHeights.length - 1]?.start, - }); - } - }, [pomHeights]); - const confirm = () => { dispatch(voteEdited([{ address: address || host, @@ -105,9 +90,9 @@ const AddVote = ({ />
- {pomHeights?.length > 0 && ( + {!start && ( <> - + )} @@ -139,24 +124,7 @@ const AddVote = ({ ); }; -const apis = { - account: { - apiUtil: (network, { token, ...params }) => getAccount({ network, params }, token), - getApiParams: (state, props) => ({ - token: tokenMap.LSK.key, - address: selectSearchParamValue(props.history.location.search, 'address'), - network: state.network, - }), - transformResponse: response => response, - }, - block: { - apiUtil: (network, params) => getBlock({ network, params }), - transformResponse: response => (response.data && response.data[0]), - }, -}; - export default compose( withRouter, - withData(apis), withTranslation(), )(AddVote); diff --git a/src/components/screens/wallet/overview/balanceInfo/index.js b/src/components/screens/wallet/overview/balanceInfo/index.js index a890cd36c4..cc781915f5 100644 --- a/src/components/screens/wallet/overview/balanceInfo/index.js +++ b/src/components/screens/wallet/overview/balanceInfo/index.js @@ -27,6 +27,7 @@ const BalanceInfo = ({ address, username, isBanned, + pomHeights, }) => { const hostBalance = useSelector(selectAccountBalance); const disableButtons = hostBalance === 0; @@ -35,6 +36,10 @@ const BalanceInfo = ({ ? {} : { recipient: address }; + const pomStart = pomHeights?.length + ? { ...pomHeights[pomHeights.length - 1] } + : {}; + const voteButtonTitle = vote ? t('Edit vote') : t('Add to votes'); const sendTitle = isWalletRoute @@ -70,6 +75,7 @@ const BalanceInfo = ({ username ? ( Date: Wed, 27 Oct 2021 10:51:55 +0200 Subject: [PATCH 24/34] Use pomHeight form the properties --- .../shared/warnPunishedDelegate/index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 850a3c7543..50b9e248ac 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -13,25 +13,26 @@ const mapStateToProps = (state) => ({ currentHeight: state.blocks.latestBlocks.length ? state.blocks.latestBlocks[0].height : 0, }); -const getPunishmentDetails = (punishedTimestamp, pomHeights, currentHeight) => { - const { end } = pomHeights && pomHeights[pomHeights.length - 1]; +const getPunishmentDetails = (punishedTimestamp, pomHeight, currentHeight) => { const startDate = new Date(punishedTimestamp * 1000); const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); // 6: blocks per minute, 60: minutes, 24: hours const numOfBlockPerDay = 24 * 60 * 6; - const daysLeft = Math.ceil((end - currentHeight) / numOfBlockPerDay); + const daysLeft = Math.ceil((pomHeight.end - currentHeight) / numOfBlockPerDay); return { daysLeft, punishmentStartDate }; }; const Warning = ({ vote, ...props }) => { useEffect(() => { - props.block.loadData(); - }, []); + if (props.pomHeight.start && props.currentHeight && !props.block.data) { + props.block.loadData(); + } + }, [props.pomHeight]); const { daysLeft, punishmentStartDate } = getPunishmentDetails( props.block.data.timestamp, - props.pomHeights, + props.pomHeight, props.currentHeight, ); @@ -52,9 +53,10 @@ const apis = { block: { apiUtil: (network, params) => getBlock({ network, params }), getApiParams: (_, ownProps) => ({ - height: ownProps.pomHeights[ownProps.pomHeights.length - 1]?.start, + height: ownProps.pomHeight.start, }), transformResponse: response => (response.data && response.data[0]), + autoLoad: false, }, }; From 82b27bde079abb360aa8278a9e9fc3249d2dbaeb Mon Sep 17 00:00:00 2001 From: reyraa Date: Wed, 27 Oct 2021 10:52:08 +0200 Subject: [PATCH 25/34] Pass pomHeight to the warning component --- src/components/screens/wallet/overview/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 12b8e50af3..04711b0489 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -15,11 +15,11 @@ import AccountInfo from './accountInfo'; import BalanceInfo from './balanceInfo'; import styles from './overview.css'; -const addWarningMessage = ({ isBanned, pomHeights, readMore }) => { +const addWarningMessage = ({ isBanned, pomHeight, readMore }) => { FlashMessageHolder.addMessage( , 'WarnPunishedDelegate', @@ -65,7 +65,7 @@ const Overview = ({ if (!isWalletRoute && host && address && (isBanned || pomHeights?.length)) { addWarningMessage({ isBanned, - pomHeights, + pomHeight: pomHeights[pomHeights.length - 1], readMore: () => { // TODO define blog entry url const url = ''; @@ -123,6 +123,7 @@ const Overview = ({ username={account?.dpos?.delegate?.username} address={address} isBanned={isBanned} + pomHeights={pomHeights} />
Date: Wed, 27 Oct 2021 15:28:54 +0100 Subject: [PATCH 26/34] Resolve development merge conflicts --- src/components/shared/warnPunishedDelegate/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 257ffd53bf..912921a7a6 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -19,7 +19,6 @@ const getPunishmentDetails = (punishedTimestamp, pomHeight, currentHeight) => { // 6: blocks per minute, 60: minutes, 24: hours const numOfBlockPerDay = 24 * 60 * 6; const daysLeft = Math.ceil((pomHeight.end - currentHeight) / numOfBlockPerDay); - console.log({ daysLeft, punishmentStartDate }); return { daysLeft, punishmentStartDate }; }; From cfe31d13f394a0f615cb6f15ebf3d88cb8a6c882 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Wed, 27 Oct 2021 15:40:00 +0100 Subject: [PATCH 27/34] Resolve development merge conflicts --- src/components/shared/warnPunishedDelegate/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 912921a7a6..377a320e35 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -24,7 +24,7 @@ const getPunishmentDetails = (punishedTimestamp, pomHeight, currentHeight) => { const Warning = ({ vote, ...props }) => { useEffect(() => { - if (props) { + if (props.pomHeight.start && props.currentHeight) { props.block.loadData(); } }, [props.pomHeight]); From 60f169c58d09ff8f162067ebb9746579a5444104 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Thu, 28 Oct 2021 08:27:49 +0100 Subject: [PATCH 28/34] NaN fixes --- src/components/screens/editVote/index.js | 7 +++--- .../shared/warnPunishedDelegate/index.js | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index cdb5db2b5e..07851bc888 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -37,8 +37,9 @@ const getTitles = t => ({ // eslint-disable-next-line max-statements const AddVote = ({ - history, t, start, end, + history, t, pomStart, ...props }) => { + console.log('Add Vote', pomStart, props); const dispatch = useDispatch(); const { account, network, voting } = useSelector(state => state); const host = useSelector(state => state.account.info.LSK.summary.address); @@ -96,9 +97,9 @@ const AddVote = ({ />
- {!start && ( + {!pomStart && ( <> - + )} diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 377a320e35..a7ce9dca41 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -18,16 +18,20 @@ const getPunishmentDetails = (punishedTimestamp, pomHeight, currentHeight) => { const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); // 6: blocks per minute, 60: minutes, 24: hours const numOfBlockPerDay = 24 * 60 * 6; + console.log('daysLeft', pomHeight); const daysLeft = Math.ceil((pomHeight.end - currentHeight) / numOfBlockPerDay); + console.log('daysLeft', daysLeft); return { daysLeft, punishmentStartDate }; }; const Warning = ({ vote, ...props }) => { useEffect(() => { - if (props.pomHeight.start && props.currentHeight) { + if (props.pomHeight.start) { props.block.loadData(); } - }, [props.pomHeight]); + }, [props.pomHeight.start]); + + console.log('-----', vote, props); const { daysLeft, punishmentStartDate } = getPunishmentDetails( props.block.data.timestamp, @@ -36,11 +40,11 @@ const Warning = ({ vote, ...props }) => { ); if (vote) { - return ; + ; } return ( - { ); }; +export const DelegateProfileWarning = ({ daysLeft, punishmentStartDate, ...props }) => ( + +); + +export const EditVoteWarning = ({ daysLeft, ...props }) => ( + +); + const apis = { block: { apiUtil: (network, params) => getBlock({ network, params }), From 31ecdd5bd400f0f15d5869d2d069b02bf0588c32 Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 28 Oct 2021 10:08:27 +0200 Subject: [PATCH 29/34] Fix pomStart passdown --- src/components/screens/editVote/index.js | 9 +++++---- .../screens/wallet/overview/balanceInfo/actionBar.js | 3 +-- src/components/screens/wallet/overview/index.js | 4 +++- src/components/shared/warnPunishedDelegate/index.js | 4 ---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/screens/editVote/index.js b/src/components/screens/editVote/index.js index 07851bc888..c89913ffba 100644 --- a/src/components/screens/editVote/index.js +++ b/src/components/screens/editVote/index.js @@ -37,13 +37,14 @@ const getTitles = t => ({ // eslint-disable-next-line max-statements const AddVote = ({ - history, t, pomStart, ...props + history, t, }) => { - console.log('Add Vote', pomStart, props); const dispatch = useDispatch(); const { account, network, voting } = useSelector(state => state); const host = useSelector(state => state.account.info.LSK.summary.address); const address = selectSearchParamValue(history.location.search, 'address'); + const start = selectSearchParamValue(history.location.search, 'start'); + const end = selectSearchParamValue(history.location.search, 'end'); const existingVote = useSelector(state => state.voting[address || host]); const balance = useSelector(selectAccountBalance); const [voteAmount, setVoteAmount] = useVoteAmountField(existingVote ? fromRawLsk(existingVote.unconfirmed) : ''); @@ -97,9 +98,9 @@ const AddVote = ({ />
- {!pomStart && ( + {start !== undefined && ( <> - + )} diff --git a/src/components/screens/wallet/overview/balanceInfo/actionBar.js b/src/components/screens/wallet/overview/balanceInfo/actionBar.js index ba9027f147..13f68ac517 100644 --- a/src/components/screens/wallet/overview/balanceInfo/actionBar.js +++ b/src/components/screens/wallet/overview/balanceInfo/actionBar.js @@ -11,8 +11,7 @@ import styles from './balanceInfo.css'; // eslint-disable-next-line complexity const ActionBar = ({ - username, address, t, isWalletRoute, activeToken, isBanned, - pomStart, + username, address, t, isWalletRoute, activeToken, isBanned, pomStart, }) => { const hostBalance = useSelector(selectAccountBalance); const disableButtons = hostBalance === 0; diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 04711b0489..3c1c810b28 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -123,7 +123,9 @@ const Overview = ({ username={account?.dpos?.delegate?.username} address={address} isBanned={isBanned} - pomHeights={pomHeights} + pomStart={pomHeights?.length + ? { ...pomHeights[pomHeights.length - 1] } + : {}} />
{ const punishmentStartDate = moment(startDate).format('MM.DD.YYYY'); // 6: blocks per minute, 60: minutes, 24: hours const numOfBlockPerDay = 24 * 60 * 6; - console.log('daysLeft', pomHeight); const daysLeft = Math.ceil((pomHeight.end - currentHeight) / numOfBlockPerDay); - console.log('daysLeft', daysLeft); return { daysLeft, punishmentStartDate }; }; @@ -31,8 +29,6 @@ const Warning = ({ vote, ...props }) => { } }, [props.pomHeight.start]); - console.log('-----', vote, props); - const { daysLeft, punishmentStartDate } = getPunishmentDetails( props.block.data.timestamp, props.pomHeight, From 5daeafe7bfd63e6789c1475826210a58f97c86ab Mon Sep 17 00:00:00 2001 From: iris salcedo Date: Thu, 28 Oct 2021 10:12:11 +0200 Subject: [PATCH 30/34] Add missing return --- src/components/shared/warnPunishedDelegate/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/shared/warnPunishedDelegate/index.js b/src/components/shared/warnPunishedDelegate/index.js index 7212832449..f4a3f859e6 100644 --- a/src/components/shared/warnPunishedDelegate/index.js +++ b/src/components/shared/warnPunishedDelegate/index.js @@ -36,7 +36,7 @@ const Warning = ({ vote, ...props }) => { ); if (vote) { - ; + return ; } return ( From 5dd89acdeef30351475e7fce1ebd05b0dcc0c297 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Fri, 29 Oct 2021 17:10:14 +0100 Subject: [PATCH 31/34] Apply suggestions from code review Co-authored-by: Manu --- src/components/screens/wallet/overview/index.js | 2 +- .../shared/warnPunishedDelegate/warnPunishedDelegate.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 3c1c810b28..8817808552 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -35,7 +35,7 @@ const Overview = ({ activeToken, transactions, hwInfo, - discreetMode, + discreteMode, isWalletRoute, account, history, diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index e9faf4bb3c..7f05f6aee2 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -5,7 +5,6 @@ import { routes } from '@constants'; import { useTheme } from '@utils/theme'; import FlashMessage from '@toolbox/flashMessage/flashMessage'; import FlashMessageHolder from '@toolbox/flashMessage/holder'; -// import { SecondaryButton } from '@toolbox/buttons'; import Icon from '@toolbox/icon'; import styles from './warnPunishedDelegate.css'; From 915b4dda016a3ec49a75d17e145de42e5fcebf51 Mon Sep 17 00:00:00 2001 From: Gad Jacobs Date: Fri, 29 Oct 2021 17:15:40 +0100 Subject: [PATCH 32/34] Refactoring --- src/components/screens/wallet/overview/index.js | 6 +++--- .../warnPunishedDelegate/warnPunishedDelegate.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 8817808552..4f1bf825b0 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -67,7 +67,7 @@ const Overview = ({ isBanned, pomHeight: pomHeights[pomHeights.length - 1], readMore: () => { - // TODO define blog entry url + // TODO define blog entry url - #3907 const url = ''; window.open(url, '_blank', 'rel="noopener noreferrer'); }, @@ -118,7 +118,7 @@ const Overview = ({ t={t} activeToken={activeToken} balance={balance} - isDiscreetMode={discreetMode} + isDiscreteMode={discreteMode} isWalletRoute={isWalletRoute} username={account?.dpos?.delegate?.username} address={address} @@ -136,7 +136,7 @@ const Overview = ({ t={t} transactions={isWalletRoute ? confirmed : transactions.data.data} token={activeToken} - isDiscreetMode={discreetMode && host === address} + isDiscreteMode={discreteMode && host === address} balance={balance} address={address} /> diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 7f05f6aee2..50ca425ed9 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -25,8 +25,14 @@ const WarnPunishedDelegate = ({ }, [history.location.pathname]); const message = isBanned - ? t('This delegate has been permanently banned from {{punishmentStartDate}}', { punishmentStartDate }) - : t('Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.', { punishmentStartDate, daysLeft }); + ? t( + 'This delegate has been permanently banned from {{punishmentStartDate}}', + { punishmentStartDate } + ) + : t( + 'Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.', + { punishmentStartDate, daysLeft } + ); return ( {`${message}`}
- {/* TODO: re-enable button when readmore blog content becomes available. */} + {/* TODO: re-enable button when readmore blog content becomes available.- #3907 */} {/* Date: Mon, 1 Nov 2021 08:54:52 +0100 Subject: [PATCH 33/34] Lint fixes --- .../warnPunishedDelegate/warnPunishedDelegate.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js index 50ca425ed9..2b89ad41b9 100644 --- a/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js +++ b/src/components/shared/warnPunishedDelegate/warnPunishedDelegate.js @@ -26,13 +26,13 @@ const WarnPunishedDelegate = ({ const message = isBanned ? t( - 'This delegate has been permanently banned from {{punishmentStartDate}}', - { punishmentStartDate } - ) + 'This delegate has been permanently banned from {{punishmentStartDate}}', + { punishmentStartDate }, + ) : t( - 'Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.', - { punishmentStartDate, daysLeft } - ); + 'Caution! This delegate was punished on {{punishmentStartDate}}. There is approximately {{daysLeft}} days remaining before the punishment ends.', + { punishmentStartDate, daysLeft }, + ); return ( Date: Mon, 1 Nov 2021 09:47:00 +0100 Subject: [PATCH 34/34] Typo fix --- src/components/screens/wallet/overview/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/screens/wallet/overview/index.js b/src/components/screens/wallet/overview/index.js index 4f1bf825b0..0a6ba82141 100644 --- a/src/components/screens/wallet/overview/index.js +++ b/src/components/screens/wallet/overview/index.js @@ -35,7 +35,7 @@ const Overview = ({ activeToken, transactions, hwInfo, - discreteMode, + discreetMode, isWalletRoute, account, history, @@ -118,7 +118,7 @@ const Overview = ({ t={t} activeToken={activeToken} balance={balance} - isDiscreteMode={discreteMode} + isDiscreetMode={discreetMode} isWalletRoute={isWalletRoute} username={account?.dpos?.delegate?.username} address={address} @@ -136,7 +136,7 @@ const Overview = ({ t={t} transactions={isWalletRoute ? confirmed : transactions.data.data} token={activeToken} - isDiscreteMode={discreteMode && host === address} + isDiscreetMode={discreetMode && host === address} balance={balance} address={address} />