From b62def9a8704af47013c58b6ef8b67515b6b16eb Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 1 Nov 2020 09:50:33 +0100 Subject: [PATCH] Allow selection of payment destination (#3956) --- .../src/Actions/partials/Bond.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/page-staking/src/Actions/partials/Bond.tsx b/packages/page-staking/src/Actions/partials/Bond.tsx index ecc87ad2d5..0525c0e7fc 100644 --- a/packages/page-staking/src/Actions/partials/Bond.tsx +++ b/packages/page-staking/src/Actions/partials/Bond.tsx @@ -31,6 +31,7 @@ function Bond ({ className = '', onChange }: Props): React.ReactElement { const [controllerError, setControllerError] = useState(false); const [controllerId, setControllerId] = useState(null); const [destination, setDestination] = useState('Staked'); + const [destAccount, setDestAccount] = useState(null); const [stashId, setStashId] = useState(null); const [startBalance, setStartBalance] = useState(null); const stashBalance = useCall(api.derive.balances.all, [stashId]); @@ -59,11 +60,15 @@ function Bond ({ className = '', onChange }: Props): React.ReactElement { }, [stashId]); useEffect((): void => { + const bondDest = destination === 'Account' + ? { Account: destAccount } + : destination; + onChange( (amount && amount.gtn(0) && !amountError?.error && !controllerError && controllerId && stashId) ? { - bondOwnTx: api.tx.staking.bond(stashId, amount, destination), - bondTx: api.tx.staking.bond(controllerId, amount, destination), + bondOwnTx: api.tx.staking.bond(stashId, amount, bondDest), + bondTx: api.tx.staking.bond(controllerId, amount, bondDest), controllerId, controllerTx: api.tx.staking.setController(controllerId), stashId @@ -76,9 +81,10 @@ function Bond ({ className = '', onChange }: Props): React.ReactElement { stashId: null } ); - }, [api, amount, amountError, controllerError, controllerId, destination, stashId, onChange]); + }, [api, amount, amountError, controllerError, controllerId, destination, destAccount, stashId, onChange]); const hasValue = !!amount?.gtn(0); + const isAccount = destination === 'Account'; return (
@@ -156,6 +162,15 @@ function Bond ({ className = '', onChange }: Props): React.ReactElement { options={options} value={destination} /> + {isAccount && ( + + )}

{t('Rewards (once paid) can be deposited to either the stash or controller, with different effects.')}