diff --git a/package.json b/package.json index 59850cec3e..c4b742a763 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "packages/*" ], "resolutions": { - "@polkadot/api": "^0.90.0-beta.22", - "@polkadot/api-contract": "^0.90.0-beta.22", + "@polkadot/api": "^0.90.0-beta.29", + "@polkadot/api-contract": "^0.90.0-beta.29", "@polkadot/keyring": "^1.0.1", - "@polkadot/types": "^0.90.0-beta.22", + "@polkadot/types": "^0.90.0-beta.29", "@polkadot/util": "^1.0.1", "@polkadot/util-crypto": "^1.0.1", "@types/styled-components": "4.1.8", @@ -34,7 +34,7 @@ "devDependencies": { "@babel/core": "^7.5.5", "@babel/runtime": "^7.5.5", - "@polkadot/dev-react": "^0.30.0-beta.24", + "@polkadot/dev-react": "^0.30.0-beta.26", "@polkadot/ts": "^0.1.63", "autoprefixer": "^9.6.1", "empty": "^0.10.1", diff --git a/packages/app-contracts/package.json b/packages/app-contracts/package.json index b18b312ea2..be8661c8b9 100644 --- a/packages/app-contracts/package.json +++ b/packages/app-contracts/package.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.5.5", - "@polkadot/api-contract": "^0.90.0-beta.22", + "@polkadot/api-contract": "^0.90.0-beta.29", "@polkadot/ui-app": "^0.34.0-beta.109" } } diff --git a/packages/app-staking/src/Actions/Account/InputValidationSessionEd25519.tsx b/packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx similarity index 68% rename from packages/app-staking/src/Actions/Account/InputValidationSessionEd25519.tsx rename to packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx index d9c4864573..445fc0574e 100644 --- a/packages/app-staking/src/Actions/Account/InputValidationSessionEd25519.tsx +++ b/packages/app-staking/src/Actions/Account/InputValidationSessionKey.tsx @@ -6,7 +6,6 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Icon } from '@polkadot/ui-app'; -import keyring from '@polkadot/ui-keyring'; import translate from '../../translate'; @@ -29,19 +28,10 @@ class ValidateSessionEd25519 extends React.PureComponent { public static getDerivedStateFromProps ({ onError, sessionId, stashId, t }: Props, prevState: State): State | null { let error = null; - try { - const pair = keyring.getPair(sessionId); - - if (pair.type !== 'ed25519') { - error = t('The selected account is not an ed25519 (Edwards) account as required for validation'); - } else if (sessionId === stashId) { - error = t('For fund security, your session key should not match your stash key.'); - } else { - error = null; - } - } catch (e) { - // this _should_ never happen... - error = t('The account {{sessionId}} is not a valid account', { replace: { sessionId } }); + if (sessionId === stashId) { + error = t('For fund security, your session key should not match your stash key.'); + } else { + error = null; } if (error === prevState.error) { diff --git a/packages/app-staking/src/Actions/Account/InputValidationSessionSr25519.tsx b/packages/app-staking/src/Actions/Account/InputValidationSessionSr25519.tsx deleted file mode 100644 index 03c6f34329..0000000000 --- a/packages/app-staking/src/Actions/Account/InputValidationSessionSr25519.tsx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017-2019 @polkadot/ui-staking 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 { I18nProps } from '@polkadot/ui-app/types'; - -import React from 'react'; -import { Icon } from '@polkadot/ui-app'; -import keyring from '@polkadot/ui-keyring'; - -import translate from '../../translate'; - -interface Props extends I18nProps { - controllerId: string; - onError: (error: string | null) => void; - sessionId: string; - stashId: string; -} - -interface State { - error: string | null; -} - -class ValidateSessionSr25519 extends React.PureComponent { - public state: State = { - error: null - }; - - public static getDerivedStateFromProps ({ onError, sessionId, stashId, t }: Props, prevState: State): State | null { - let error = null; - - try { - const pair = keyring.getPair(sessionId); - - if (pair.type !== 'sr25519') { - error = t('The selected account is not an sr25519 (Schnorrkel) account as required for validation'); - } else if (sessionId === stashId) { - error = t('For fund security, your session key should not match your stash key.'); - } else { - error = null; - } - } catch (e) { - // this _should_ never happen... - error = t('The account {{sessionId}} is not a valid account', { replace: { sessionId } }); - } - - if (error === prevState.error) { - return null; - } - - onError(error); - - return { error }; - } - - public render (): React.ReactNode { - const { error } = this.state; - - if (!error) { - return null; - } - - return ( -
-
{error}
-
- ); - } -} - -export default translate(ValidateSessionSr25519); diff --git a/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx b/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx index a4d47a40db..496eee4f73 100644 --- a/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx +++ b/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx @@ -9,23 +9,25 @@ import React from 'react'; import { Button, InputAddress, Modal, TxButton } from '@polkadot/ui-app'; import { withApi, withMulti } from '@polkadot/ui-api'; -import ValidateSessionEd25519 from './InputValidationSessionEd25519'; -import ValidateSessionSr25519 from './InputValidationSessionSr25519'; +import ValidationSessionKey from './InputValidationSessionKey'; import translate from '../../translate'; type Props = I18nProps & ApiProps & { controllerId: string; isOpen: boolean; onClose: () => void; - sessionId?: string | null; + sessionIds: string[]; stashId: string; }; interface State { + babe: string; + babeError: string | null; + // TODO rename grandpa ed25519: string; ed25519Error: string | null; - sr25519: string; - sr25519Error: string | null; + imOnline: string; + imOnlineError: string | null; } class SetSessionKey extends React.PureComponent { @@ -35,22 +37,24 @@ class SetSessionKey extends React.PureComponent { super(props); this.state = { - ed25519: props.sessionId || props.controllerId, + babe: props.sessionIds[1] || props.controllerId, + babeError: null, + ed25519: props.sessionIds[0] || props.controllerId, ed25519Error: null, - sr25519: '', - sr25519Error: null + imOnline: props.sessionIds[2] || props.controllerId, + imOnlineError: null }; } public render (): React.ReactNode { const { controllerId, isOpen, isSubstrateV2, onClose, t } = this.props; - const { ed25519, ed25519Error, sr25519, sr25519Error } = this.state; + const { ed25519, ed25519Error, babe, babeError, imOnline, imOnlineError } = this.state; if (!isOpen) { return null; } - const hasError = !ed25519 || !!ed25519Error || (isSubstrateV2 ? (!sr25519 || !!sr25519Error) : false); + const hasError = !ed25519 || !!ed25519Error || (isSubstrateV2 ? ((!babe || !!babeError) && (!imOnline || !!imOnlineError)) : false); return ( { onClick={onClose} params={ isSubstrateV2 - ? [{ ed25519, sr25519 }, new Uint8Array([])] + ? [{ babe, grandpa: ed25519, imOnline }, new Uint8Array([])] : [ed25519] } tx={ @@ -93,7 +97,7 @@ class SetSessionKey extends React.PureComponent { private renderContent (): React.ReactNode { const { controllerId, isSubstrateV2, stashId, t } = this.props; - const { ed25519, sr25519 } = this.state; + const { ed25519, imOnline, babe } = this.state; return ( <> @@ -110,12 +114,15 @@ class SetSessionKey extends React.PureComponent { - { - + + @@ -149,20 +168,28 @@ class SetSessionKey extends React.PureComponent { ); } + private onChangeBabe = (babe: string): void => { + this.setState({ babe }); + } + private onChangeEd25519 = (ed25519: string): void => { this.setState({ ed25519 }); } - private onChangeSr25519 = (sr25519: string): void => { - this.setState({ sr25519 }); + private onChangeImOnline = (imOnline: string): void => { + this.setState({ imOnline }); + } + + private onSessionErrorBabe = (babeError: string | null): void => { + this.setState({ babeError }); } private onSessionErrorEd25519 = (ed25519Error: string | null): void => { this.setState({ ed25519Error }); } - private onSessionErrorSr25519 = (sr25519Error: string | null): void => { - this.setState({ sr25519Error }); + private onSessionErrorImOnline = (imOnlineError: string | null): void => { + this.setState({ imOnlineError }); } } diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index 5a02c4232c..ca3f95b809 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -49,7 +49,7 @@ interface State { isUnbondOpen: boolean; isValidateOpen: boolean; nominees?: string[]; - sessionId: string | null; + sessionIds: string[]; stakers?: Exposure; stakingLedger?: StakingLedger; stashId: string | null; @@ -76,7 +76,7 @@ class Account extends React.PureComponent { isStashValidating: false, isUnbondOpen: false, isValidateOpen: false, - sessionId: null, + sessionIds: [], stashId: null }; @@ -85,7 +85,7 @@ class Account extends React.PureComponent { return null; } - const { controllerId, nextSessionId, nominators, rewardDestination, stakers, stakingLedger, stashId, validatorPrefs } = staking_info; + const { controllerId, nextSessionIds, nominators, rewardDestination, sessionIds, stakers, stakingLedger, stashId, validatorPrefs } = staking_info; const isStashNominating = nominators && nominators.length !== 0; const _stashId = toIdString(stashId); const isStashValidating = !!allStashes && !!_stashId && allStashes.includes(_stashId); @@ -96,7 +96,11 @@ class Account extends React.PureComponent { isStashNominating, isStashValidating, nominees: nominators && nominators.map(toIdString), - sessionId: toIdString(nextSessionId), + sessionIds: ( + nextSessionIds.length + ? nextSessionIds + : sessionIds + ).map(toIdString), stakers, stakingLedger, stashId: _stashId, @@ -267,9 +271,9 @@ class Account extends React.PureComponent { private renderSessionAccount (): React.ReactNode { const { t } = this.props; - const { sessionId } = this.state; + const { sessionIds } = this.state; - if (!sessionId) { + if (!sessionIds.length) { return null; } @@ -277,7 +281,7 @@ class Account extends React.PureComponent {
{ private renderButtons (): React.ReactNode { const { t } = this.props; - const { controllerId, isSettingPopupOpen, isStashNominating, isStashValidating, sessionId } = this.state; + const { controllerId, isSettingPopupOpen, isStashNominating, isStashValidating, sessionIds } = this.state; const buttons = []; // if we are validating/nominating show stop @@ -350,7 +354,7 @@ class Account extends React.PureComponent { /> ); } else { - if (!sessionId) { + if (!sessionIds.length) { buttons.push(