diff --git a/packages/app-staking/src/Actions/Account/InputValidationController.tsx b/packages/app-staking/src/Actions/Account/InputValidationController.tsx index f0fcec11eb..f1660817ea 100644 --- a/packages/app-staking/src/Actions/Account/InputValidationController.tsx +++ b/packages/app-staking/src/Actions/Account/InputValidationController.tsx @@ -2,8 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { AccountId, StakingLedger } from '@polkadot/types/interfaces'; +import { ApiProps } from '@polkadot/react-api/types'; import { I18nProps } from '@polkadot/react-components/types'; +import { AccountId, StakingLedger } from '@polkadot/types/interfaces'; import React from 'react'; import { Icon } from '@polkadot/react-components'; @@ -12,7 +13,7 @@ import { withCalls } from '@polkadot/react-api'; import translate from '../../translate'; -interface Props extends I18nProps { +interface Props extends ApiProps, I18nProps { accountId: string | null; bondedId?: string | null; controllerId: string | null; @@ -37,7 +38,7 @@ class ValidateController extends React.PureComponent { // this applies when changing controller return null; } else if (controllerId === accountId) { - return t('Please select distinct stash and controller accounts'); + return t('Distinct stash and controller accounts are recommended to ensure fund security'); } else if (bondedId) { return t('A controller account should not map to another stash. This selected controller is a stash, controlled by {{bondedId}}', { replace: { bondedId } }); } else if (stashId) { diff --git a/packages/app-staking/src/Actions/Account/Validate.tsx b/packages/app-staking/src/Actions/Account/Validate.tsx index 3ef1e0a2cd..7de3e9f73c 100644 --- a/packages/app-staking/src/Actions/Account/Validate.tsx +++ b/packages/app-staking/src/Actions/Account/Validate.tsx @@ -101,7 +101,7 @@ class Validate extends TxComponent { accountId={controllerId} isDisabled={!!unstakeThresholdError} isPrimary - label={t('Validate Preferences')} + label={t('Validate')} onClick={onClose} params={[ isSubstrateV2 diff --git a/packages/app-staking/src/Actions/NewStake.tsx b/packages/app-staking/src/Actions/NewStake.tsx index 1aa921d3c6..6c06636c10 100644 --- a/packages/app-staking/src/Actions/NewStake.tsx +++ b/packages/app-staking/src/Actions/NewStake.tsx @@ -10,15 +10,17 @@ import BN from 'bn.js'; import React from 'react'; import { SubmittableExtrinsic } from '@polkadot/api/promise/types'; import { Button, Dropdown, InputAddress, InputBalanceBonded, Modal, TxButton, TxComponent } from '@polkadot/react-components'; -import { withApi, withMulti } from '@polkadot/react-api'; +import { withCalls, withMulti } from '@polkadot/react-api'; +import { Text } from '@polkadot/types'; import translate from '../translate'; -import { rewardDestinationOptions } from './constants'; import InputValidationController from './Account/InputValidationController'; +import { rewardDestinationOptions } from './constants'; -type Props = I18nProps & ApiProps & CalculateBalanceProps & { +interface Props extends ApiProps, I18nProps, CalculateBalanceProps { onClose: () => void; -}; + systemChain?: Text; +} interface State { bondValue?: BN; @@ -26,9 +28,12 @@ interface State { controllerId: string | null; destination: number; extrinsic: SubmittableExtrinsic | null; + ignoreController: boolean; stashId: string | null; } +const NO_VALIDATION_CHAINS = ['Development', 'Kusama']; + class NewStake extends TxComponent { public state: State; @@ -40,15 +45,26 @@ class NewStake extends TxComponent { controllerId: null, destination: 0, extrinsic: null, + ignoreController: false, stashId: null }; } + public static getDerivedStateFromProps ({ systemChain }: Props): Pick | null { + if (!systemChain) { + return null; + } + + return { + ignoreController: NO_VALIDATION_CHAINS.includes(systemChain.toString()) + }; + } + public render (): React.ReactNode { const { onClose, t } = this.props; - const { bondValue, controllerError, controllerId, extrinsic, stashId } = this.state; + const { bondValue, controllerError, controllerId, extrinsic, ignoreController, stashId } = this.state; const hasValue = !!bondValue && bondValue.gtn(0); - const canSubmit = hasValue && !controllerError && !!controllerId; + const canSubmit = (hasValue && (ignoreController || (!controllerError && !!controllerId))); return ( { private renderContent (): React.ReactNode { const { t } = this.props; - const { controllerId, controllerError, bondValue, destination, stashId } = this.state; + const { controllerId, controllerError, bondValue, destination, ignoreController, stashId } = this.state; const hasValue = !!bondValue && bondValue.gtn(0); return ( @@ -102,7 +118,7 @@ class NewStake extends TxComponent { { private nextState (newState: Partial): void { this.setState((prevState: State): State => { const { api } = this.props; - const { bondValue = prevState.bondValue, controllerError = prevState.controllerError, controllerId = prevState.controllerId, destination = prevState.destination, stashId = prevState.stashId } = newState; + const { bondValue = prevState.bondValue, controllerError = prevState.controllerError, controllerId = prevState.controllerId, destination = prevState.destination, ignoreController = prevState.ignoreController, stashId = prevState.stashId } = newState; const extrinsic = (bondValue && controllerId) ? api.tx.staking.bond(controllerId, bondValue, destination) : null; @@ -155,6 +171,7 @@ class NewStake extends TxComponent { controllerId, destination, extrinsic, + ignoreController, stashId }; }); @@ -184,5 +201,7 @@ class NewStake extends TxComponent { export default withMulti( NewStake, translate, - withApi + withCalls( + ['rpc.system.chain', { propName: 'systemChain' }] + ) ); diff --git a/packages/apps/src/SideBar/index.tsx b/packages/apps/src/SideBar/index.tsx index 3ff46bc90c..b678b9a049 100644 --- a/packages/apps/src/SideBar/index.tsx +++ b/packages/apps/src/SideBar/index.tsx @@ -4,6 +4,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { Route } from '@polkadot/apps-routing/types'; +import { ApiProps } from '@polkadot/react-api/types'; import { I18nProps } from '@polkadot/react-components/types'; import { SIDEBAR_MENU_THRESHOLD } from '../constants'; @@ -24,7 +25,7 @@ import Item from './Item'; import NodeInfo from './NodeInfo'; import getLogo from './logos'; -interface Props extends I18nProps { +interface Props extends ApiProps, I18nProps { collapse: () => void; handleResize: () => void; isCollapsed: boolean;