From 5e367bb41e4d1f04a96aec94d3e244d764058632 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 8 Apr 2019 08:58:41 +0200 Subject: [PATCH] Allow bonding of extra funds (#918) --- .../src/Account/{Bonding.tsx => Bond.tsx} | 4 +- .../app-staking/src/Account/BondExtra.tsx | 98 +++++++++++++++++++ packages/app-staking/src/Account/index.tsx | 58 ++++++++--- 3 files changed, 144 insertions(+), 16 deletions(-) rename packages/app-staking/src/Account/{Bonding.tsx => Bond.tsx} (97%) create mode 100644 packages/app-staking/src/Account/BondExtra.tsx diff --git a/packages/app-staking/src/Account/Bonding.tsx b/packages/app-staking/src/Account/Bond.tsx similarity index 97% rename from packages/app-staking/src/Account/Bonding.tsx rename to packages/app-staking/src/Account/Bond.tsx index b8a8c25ee5..4b483513d3 100644 --- a/packages/app-staking/src/Account/Bonding.tsx +++ b/packages/app-staking/src/Account/Bond.tsx @@ -30,7 +30,7 @@ const stashOptions = [ { text: 'Controller account', value: 2 } ]; -class Bonding extends React.PureComponent { +class Bond extends React.PureComponent { state: State = { controllerId: null, destination: 0, @@ -147,4 +147,4 @@ class Bonding extends React.PureComponent { } } -export default translate(Bonding); +export default translate(Bond); diff --git a/packages/app-staking/src/Account/BondExtra.tsx b/packages/app-staking/src/Account/BondExtra.tsx new file mode 100644 index 0000000000..c17162f8bf --- /dev/null +++ b/packages/app-staking/src/Account/BondExtra.tsx @@ -0,0 +1,98 @@ +// 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 BN from 'bn.js'; +import React from 'react'; +import { Button, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/ui-app'; + +import translate from '../translate'; + +type Props = I18nProps & { + accountId: string, + isOpen: boolean, + onClose: () => void +}; + +type State = { + maxAdditional?: BN +}; + +class BondExtra extends React.PureComponent { + state: State = {}; + + render () { + const { accountId, isOpen, onClose, t } = this.props; + const { maxAdditional } = this.state; + const canSubmit = !!maxAdditional && maxAdditional.gtn(0); + + if (!isOpen) { + return null; + } + + return ( + + {this.renderContent()} + + +