From 77907d5706fb6f2a388d14908d21cc1b7cac7c21 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 14 Nov 2019 19:31:01 +0100 Subject: [PATCH] Fix validatorPrefs (don't pull defaults) (#1885) --- .../src/Actions/Account/Validate.tsx | 59 ++++++++----------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/packages/app-staking/src/Actions/Account/Validate.tsx b/packages/app-staking/src/Actions/Account/Validate.tsx index 8464975ae7..a05be2d8cf 100644 --- a/packages/app-staking/src/Actions/Account/Validate.tsx +++ b/packages/app-staking/src/Actions/Account/Validate.tsx @@ -35,34 +35,35 @@ class Validate extends TxComponent { validatorPayment: new BN(0) }; + // FIXME Borken with new InputBalance // inject the preferences returned via RPC once into the state (from this // point forward it will be entirely managed by the actual inputs) - public static getDerivedStateFromProps ({ isSubstrateV2, validatorPrefs }: Props, state: State): Pick | null { - if (state.unstakeThreshold && state.validatorPayment) { - return null; - } + // public static getDerivedStateFromProps ({ isSubstrateV2, validatorPrefs }: Props, state: State): Pick | null { + // if (state.unstakeThreshold && state.validatorPayment) { + // return null; + // } - if (validatorPrefs) { - // 1.x, it has both values - if (isSubstrateV2) { - const { validatorPayment } = validatorPrefs as ValidatorPrefs; + // if (validatorPrefs) { + // // 1.x, it has both values + // if (isSubstrateV2) { + // const { validatorPayment } = validatorPrefs as ValidatorPrefs; - return { - validatorPayment: validatorPayment.toBn() - }; - } else { - const { unstakeThreshold, validatorPayment } = validatorPrefs as ValidatorPrefs0to145; + // return { + // validatorPayment: validatorPayment.toBn() + // }; + // } else { + // const { unstakeThreshold, validatorPayment } = validatorPrefs as ValidatorPrefs0to145; - return { - unstakeThreshold: unstakeThreshold.toBn(), - unstakeThresholdError: null, - validatorPayment: validatorPayment.toBn() - }; - } - } + // return { + // unstakeThreshold: unstakeThreshold.toBn(), + // unstakeThresholdError: null, + // validatorPayment: validatorPayment.toBn() + // }; + // } + // } - return null; - } + // return null; + // } public render (): React.ReactNode { const { isOpen } = this.props; @@ -120,7 +121,7 @@ class Validate extends TxComponent { private renderContent (): React.ReactNode { const { controllerId, isSubstrateV2, stashId, t, validatorPrefs } = this.props; - const { unstakeThreshold, unstakeThresholdError, validatorPayment } = this.state; + const { unstakeThreshold, unstakeThresholdError } = this.state; const defaultThreshold = validatorPrefs && (validatorPrefs as ValidatorPrefs0to145).unstakeThreshold && (validatorPrefs as ValidatorPrefs0to145).unstakeThreshold.toBn(); return ( @@ -153,11 +154,6 @@ class Validate extends TxComponent { label={t('automatic unstake threshold')} onChange={this.onChangeThreshold} onEnter={this.sendTx} - value={ - unstakeThreshold - ? unstakeThreshold.toString() - : '3' - } /> { )}