From b33064150971a9701b3b96a88c8ef84705107715 Mon Sep 17 00:00:00 2001
From: Aaron Cox
Date: Mon, 13 Nov 2017 15:15:49 -0500
Subject: [PATCH] Better delegation controls
Fixes #18
---
app/components/Accounts/Delegation.js | 82 +++++++++++++++++++++------
1 file changed, 66 insertions(+), 16 deletions(-)
diff --git a/app/components/Accounts/Delegation.js b/app/components/Accounts/Delegation.js
index 6fa652c..f1da69e 100644
--- a/app/components/Accounts/Delegation.js
+++ b/app/components/Accounts/Delegation.js
@@ -47,20 +47,28 @@ export default class AccountsProxy extends Component {
this.resetState();
}
handleOnChange = (value) => {
- const vests = parseFloat(value).toFixed(6);
+ const parsed = parseFloat(value)
+ if (Number.isNaN(parsed)) {
+ return
+ }
+ const vests = parsed.toFixed(6);
const props = this.props.steem.props;
const totalVestsSteem = parseFloat(props.total_vesting_fund_steem.split(" ")[0])
const totalVests = parseFloat(props.total_vesting_shares.split(" ")[0])
- const sp = totalVestsSteem * vests / totalVests;
+ const sp = (totalVestsSteem * vests / totalVests).toFixed(3);
this.setState({ vests, sp });
}
handleOnChangeComplete = (value) => {
- const vests = parseFloat(value).toFixed(6);
+ const parsed = parseFloat(value)
+ if (Number.isNaN(parsed)) {
+ return
+ }
+ const vests = parsed.toFixed(6);
const props = this.props.steem.props;
const totalVestsSteem = parseFloat(props.total_vesting_fund_steem.split(" ")[0])
const totalVests = parseFloat(props.total_vesting_shares.split(" ")[0])
- const sp = totalVestsSteem * vests / totalVests;
+ const sp = (totalVestsSteem * vests / totalVests).toFixed(3);
this.setState({ vests, sp });
}
handleVestingSharesRemove = (e, props) => {
@@ -93,6 +101,29 @@ export default class AccountsProxy extends Component {
this.props.actions.useKey('setDelegateVestingShares', { delegator, delegatee, vestingShares: vests }, permissions[delegator])
e.preventDefault();
}
+ handleOnChangeInput = (e, props) => {
+ const { name, value } = props
+ const globalProps = this.props.steem.props;
+ const totalVestsSteem = parseFloat(globalProps.total_vesting_fund_steem.split(" ")[0])
+ const totalVests = parseFloat(globalProps.total_vesting_shares.split(" ")[0])
+ const parsed = parseFloat(value)
+ let vests, sp
+ if (Number.isNaN(parsed)) {
+ this.setState({ [name]: value });
+ return
+ }
+ if (name === 'vests') {
+ const fixed = parsed.toFixed(6);
+ sp = (totalVestsSteem * fixed / totalVests).toFixed(3)
+ vests = value
+ }
+ if (name === 'sp') {
+ const fixed = parsed.toFixed(3);
+ sp = value
+ vests = (fixed / totalVestsSteem * totalVests).toFixed(6)
+ }
+ this.setState({ vests, sp });
+ }
handleChangeVestingShares = (e, props) => {
const editing = this.state.editDelegationFor;
const newState = {};
@@ -152,18 +183,37 @@ export default class AccountsProxy extends Component {
Please enter the name of the target account that you wish to delegate
a portion of the {name} account's vested weight to.
-
-
-
- Use the slider to determine how much of your VESTS to delegate. If you are editing an existing delegation, set the value to the new total you wish to delegate.
-
+
+
+ Delegatee Account Name
+
+
+
+ Steem Power
+
+
+
+ Vesting Shares
+
+
+