From 653c4139687fab43ff514426bc5c271308ec0a96 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Wed, 13 Dec 2017 19:08:20 -0500 Subject: [PATCH] Added a message about overwriting delegations within prompts Fixes #57 --- app/components/sign/operations/prompt.js | 2 +- .../sign/operations/types/delegation.js | 19 +++++++++++++++++++ app/containers/PromptOperation.js | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/components/sign/operations/prompt.js b/app/components/sign/operations/prompt.js index 03c36f6..8fa39d2 100644 --- a/app/components/sign/operations/prompt.js +++ b/app/components/sign/operations/prompt.js @@ -202,7 +202,7 @@ export default class OperationsPrompt extends Component { case 'delegate_vesting_shares': return [
Delegate Steem Power
, - + ] case 'transfer': return [ diff --git a/app/components/sign/operations/types/delegation.js b/app/components/sign/operations/types/delegation.js index 01d22f7..0b93b01 100644 --- a/app/components/sign/operations/types/delegation.js +++ b/app/components/sign/operations/types/delegation.js @@ -19,6 +19,24 @@ export default class OperationsPromptDelegation extends Component { const totalVestsSteem = parseFloat(this.props.steem.props.total_vesting_fund_steem.split(" ")[0]) const totalVests = parseFloat(this.props.steem.props.total_vesting_shares.split(" ")[0]) const sp = (vests > 0) ? (totalVestsSteem * vests / totalVests).toFixed(3) : 0 + let existingDelegation = 0 + let existingDelegationWarning = false + if (this.props.account.vestingDelegations && this.props.account.vestingDelegations[opData.delegator]) { + const existingDelegations = this.props.account.vestingDelegations[opData.delegator] + existingDelegation = existingDelegations.reduce((a, b) => (b.delegator === opData.delegator && b.delegatee === opData.delegatee) ? a + parseFloat(b.vesting_shares.split(" ")[0]) : 0, 0) + if(existingDelegation > 0) { + const existingSp = (existingDelegation * vests / totalVests).toFixed(3) + existingDelegationWarning = ( + + + + A delegation of {existingSp} SP ({existingDelegation} VESTS) is already active from to . This new delegation will overwrite the existing delegation (not add to it). + + + + ) + } + } const numberFormat = { shortFormat: true, shortFormatMinValue: 1000 @@ -67,6 +85,7 @@ export default class OperationsPromptDelegation extends Component { + {existingDelegationWarning} ) diff --git a/app/containers/PromptOperation.js b/app/containers/PromptOperation.js index 366883f..af07ea9 100644 --- a/app/containers/PromptOperation.js +++ b/app/containers/PromptOperation.js @@ -124,9 +124,10 @@ class PromptOperation extends Component { render() { const { ops, meta } = this.state - const { keys } = this.props + const { account, keys } = this.props return (