diff --git a/packages/apps/public/locales/en/app-staking.json b/packages/apps/public/locales/en/app-staking.json index 1771e3a1a1..e777950aa4 100644 --- a/packages/apps/public/locales/en/app-staking.json +++ b/packages/apps/public/locales/en/app-staking.json @@ -26,6 +26,7 @@ "Changing the key only takes effect at the start of the next session. The input here is generates from the author_rotateKeys command": "Changing the key only takes effect at the start of the next session. The input here is generates from the author_rotateKeys command", "Chilled ({{count}})": "Chilled ({{count}})", "Chilled nominations ({{count}})": "Chilled nominations ({{count}})", + "Controller account": "Controller account", "Display overview information for the selected validator, including blocks produced.": "Display overview information for the selected validator, including blocks produced.", "Distinct stash and controller accounts are recommended to ensure fund security. You will be allowed to make the transaction, but take care to not tie up all funds, only use a portion of the available funds during this period.": "Distinct stash and controller accounts are recommended to ensure fund security. You will be allowed to make the transaction, but take care to not tie up all funds, only use a portion of the available funds during this period.", "Ensure that not all funds are locked, funds need to be available for fees.": "Ensure that not all funds are locked, funds need to be available for fees.", @@ -69,6 +70,7 @@ "Oversubscribed": "Oversubscribed", "Oversubscribed nominations ({{count}})": "Oversubscribed nominations ({{count}})", "Parachains": "Parachains", + "Payment account": "Payment account", "Payout": "Payout", "Payout all": "Payout all", "Payout all stakers": "Payout all stakers", @@ -95,8 +97,11 @@ "Slashed in era {{eras}}": "Slashed in era {{eras}}", "Slashes": "Slashes", "Slashes ({{count}})": "Slashes ({{count}})", + "Specific payment account": "Specific payment account", "Staking overview": "Staking overview", "Stash": "Stash", + "Stash account (do not increase the amount at stake)": "Stash account (do not increase the amount at stake)", + "Stash account (increase the amount at stake)": "Stash account (increase the amount at stake)", "Stop": "Stop", "Submit key": "Submit key", "Targets": "Targets", diff --git a/packages/apps/public/locales/en/translation.json b/packages/apps/public/locales/en/translation.json index 284b5758be..3067f821d0 100644 --- a/packages/apps/public/locales/en/translation.json +++ b/packages/apps/public/locales/en/translation.json @@ -119,6 +119,7 @@ "Constants": "", "Continue": "", "Contracts": "", + "Controller account": "", "Conviction locks do overlap and is additive, meaning that funds locked during a previous vote can be locked again.": "", "Copy the above string and sign an Ethereum transaction with the account you used during the pre-sale in the wallet of your choice, using the string as the payload, and then paste the transaction signature object below": "", "Council": "", @@ -316,6 +317,7 @@ "Parachains": "", "Parachains overview": "", "Paste here the address of the contact you want to add to your address book.": "", + "Payment account": "", "Payout": "", "Payout all": "", "Payout all stakers": "", @@ -437,6 +439,7 @@ "Slashed": "", "Society": "", "Society overview": "", + "Specific payment account": "", "Specify the user account to use for this contract call. And fees will be deducted from this account.": "", "Specify the user account to use for this deployment. And fees will be deducted from this account.": "", "Specify the user account to use for this deployment. Any fees will be deducted from this account.": "", @@ -453,6 +456,8 @@ "Start generation": "", "Start recovery": "", "Stash": "", + "Stash account (do not increase the amount at stake)": "", + "Stash account (increase the amount at stake)": "", "Stop": "", "Stop generation": "", "Storage": "", diff --git a/packages/page-staking/src/Actions/Account/SetRewardDestination.tsx b/packages/page-staking/src/Actions/Account/SetRewardDestination.tsx index 4657db636b..60d8cff26e 100644 --- a/packages/page-staking/src/Actions/Account/SetRewardDestination.tsx +++ b/packages/page-staking/src/Actions/Account/SetRewardDestination.tsx @@ -5,11 +5,11 @@ import { RewardDestination } from '@polkadot/types/interfaces'; import { DestinationType } from '../types'; -import React, { useState } from 'react'; +import React, { useMemo, useState } from 'react'; import { Dropdown, InputAddress, Modal, TxButton } from '@polkadot/react-components'; import { useTranslation } from '../../translate'; -import { rewardDestinationOptions, rewardDestinationOptionsPrev } from '../constants'; +import { createDestCurr, createDestPrev } from '../destOptions'; interface Props { defaultDestination?: RewardDestination; @@ -23,9 +23,13 @@ function SetRewardDestination ({ controllerId, defaultDestination, onClose, stas const [destination, setDestination] = useState(((defaultDestination?.isAccount ? 'Account' : defaultDestination?.toString()) || 'Staked') as 'Staked'); const [destAccount, setDestAccount] = useState(defaultDestination?.isAccount ? defaultDestination.asAccount.toString() : null); - const options = defaultDestination?.isAccount - ? rewardDestinationOptions - : rewardDestinationOptionsPrev; + const options = useMemo( + () => defaultDestination?.isAccount + ? createDestCurr(t) + : createDestPrev(t), + [defaultDestination, t] + ); + const isAccount = destination === 'Account'; return ( diff --git a/packages/page-staking/src/Actions/constants.tsx b/packages/page-staking/src/Actions/constants.tsx deleted file mode 100644 index 86280f3a4f..0000000000 --- a/packages/page-staking/src/Actions/constants.tsx +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017-2020 @polkadot/react-components authors & contributors -// This software may be modified and distributed under the terms -// of the Apache-2.0 license. See the LICENSE file for details. - -export const rewardDestinationOptionsPrev = [ - { text: 'Stash account (increase the amount at stake)', value: 'Staked' }, - { text: 'Stash account (do not increase the amount at stake)', value: 'Stash' }, - { text: 'Controller account', value: 'Controller' } -]; - -export const rewardDestinationOptions = [ - ...rewardDestinationOptionsPrev, - { text: 'Payment account', value: 'Account' } -]; diff --git a/packages/page-staking/src/Actions/destOptions.tsx b/packages/page-staking/src/Actions/destOptions.tsx new file mode 100644 index 0000000000..46ff2ef8be --- /dev/null +++ b/packages/page-staking/src/Actions/destOptions.tsx @@ -0,0 +1,22 @@ +// Copyright 2017-2020 @polkadot/react-components authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { TFunction } from 'i18next'; + +interface Option { + text: string; + value: string; +} + +export function createDestPrev (t: TFunction): Option[] { + return [ + { text: t('Stash account (increase the amount at stake)'), value: 'Staked' }, + { text: t('Stash account (do not increase the amount at stake)'), value: 'Stash' }, + { text: t('Controller account'), value: 'Controller' } + ]; +} + +export function createDestCurr (t: TFunction): Option[] { + return createDestPrev(t).concat({ text: t('Specified payment account'), value: 'Account' }); +} diff --git a/packages/page-staking/src/Actions/partials/Bond.tsx b/packages/page-staking/src/Actions/partials/Bond.tsx index f615f9cfa5..df8e41f120 100644 --- a/packages/page-staking/src/Actions/partials/Bond.tsx +++ b/packages/page-staking/src/Actions/partials/Bond.tsx @@ -7,7 +7,7 @@ import { AmountValidateState, DestinationType } from '../types'; import { BondInfo } from './types'; import BN from 'bn.js'; -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Dropdown, InputAddress, InputBalance, Modal, Static } from '@polkadot/react-components'; import { BalanceFree, BlockToTime } from '@polkadot/react-query'; import { useApi, useCall } from '@polkadot/react-hooks'; @@ -16,7 +16,7 @@ import { BN_ZERO } from '@polkadot/util'; import { useTranslation } from '../../translate'; import InputValidateAmount from '../Account/InputValidateAmount'; import InputValidationController from '../Account/InputValidationController'; -import { rewardDestinationOptionsPrev } from '../constants'; +import { createDestPrev } from '../destOptions'; import useUnbondDuration from '../useUnbondDuration'; interface Props { @@ -37,6 +37,11 @@ function Bond ({ className = '', onChange }: Props): React.ReactElement { const stashBalance = useCall(api.derive.balances.all, [stashId]); const bondedBlocks = useUnbondDuration(); + const options = useMemo( + () => createDestPrev(t), + [t] + ); + const _setError = useCallback( // eslint-disable-next-line handle-callback-err (error: string | null, isFatal: boolean) => setControllerError(isFatal), @@ -150,7 +155,7 @@ function Bond ({ className = '', onChange }: Props): React.ReactElement { help={t('The destination account for any payments as either a nominator or validator')} label={t('payment destination')} onChange={setDestination} - options={rewardDestinationOptionsPrev} + options={options} value={destination} />