From 3bfa8e9aaa5175fd16cc44c20b6764a061061dfb Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Fri, 15 Mar 2019 17:01:39 +0200 Subject: [PATCH 01/12] add transferOperation --- app/components/Account/Proposals.jsx | 4 +- .../Blockchain/ProposedOperation.jsx | 83 ++++--------------- .../Blockchain/operations/Transfer.jsx | 60 ++++++++++++++ 3 files changed, 79 insertions(+), 68 deletions(-) create mode 100644 app/components/Blockchain/operations/Transfer.jsx diff --git a/app/components/Account/Proposals.jsx b/app/components/Account/Proposals.jsx index 60a673738b..3fdd578ab9 100644 --- a/app/components/Account/Proposals.jsx +++ b/app/components/Account/Proposals.jsx @@ -144,14 +144,14 @@ class Proposals extends Component { touchedAccounts.push(proposer); - if (__DEV__) { + /* if (__DEV__) { console.log( "Proposed transactions: ", proposal, " touching accounts ", touchedAccounts ); - } + } */ touchedAccounts.forEach(_account => { if (accountUtils.isKnownScammer(_account)) { diff --git a/app/components/Blockchain/ProposedOperation.jsx b/app/components/Blockchain/ProposedOperation.jsx index bb8a4b148d..de144e1e25 100644 --- a/app/components/Blockchain/ProposedOperation.jsx +++ b/app/components/Blockchain/ProposedOperation.jsx @@ -16,6 +16,7 @@ import MemoText from "./MemoText"; import TranslateWithLinks from "../Utility/TranslateWithLinks"; const {operations} = grapheneChainTypes; import PropTypes from "prop-types"; +import TransferOperation from "./operations/Transfer"; require("./operations.scss"); @@ -87,6 +88,10 @@ class Row extends React.Component { } class ProposedOperation extends React.Component { + state = { + label_color: "info" + }; + static defaultProps = { op: [], current: "", @@ -128,6 +133,14 @@ class ProposedOperation extends React.Component { ); } + changeColor = newColor => { + const {label_color} = this.state; + if (label_color !== newColor) { + console.log("!!!! change color", newColor); + this.setState({label_color: newColor}); + } + }; + render() { let {op, proposer, current, block, hideExpiration, index} = this.props; let line = null, @@ -138,58 +151,11 @@ class ProposedOperation extends React.Component { ops[op[0]] // For a list of trx types, see chain_types.coffee ) { case "transfer": - let memoComponent = null; - - if (op[1].memo) { - memoComponent = ; - } - - color = "success"; - op[1].amount.amount = parseFloat(op[1].amount.amount); - column = ( - -
- {!!proposer && index == 0 ? ( -
- - : -
- ) : null} -
- - {memoComponent} -
-
-
+ ); break; @@ -382,21 +348,6 @@ class ProposedOperation extends React.Component { ); - // if (current === op[1].authorizing_account) { - // column = ( - // - // - //  {this.linkToAccount(op[1].account_to_list)} - // - // ); - // } else { - // column = ( - // - // - //  {this.linkToAccount(op[1].authorizing_account)} - // - // ); - // } break; case "account_upgrade": diff --git a/app/components/Blockchain/operations/Transfer.jsx b/app/components/Blockchain/operations/Transfer.jsx new file mode 100644 index 0000000000..12f401decd --- /dev/null +++ b/app/components/Blockchain/operations/Transfer.jsx @@ -0,0 +1,60 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; +import MemoText from "../MemoText"; + +const TransferOperation = ({op, proposer, index, changeColor}) => { + changeColor("success"); + let memoComponent = null; + + if (op[1].memo) { + memoComponent = ; + } + op[1].amount.amount = parseFloat(op[1].amount.amount); + + return ( + +
+ {!!proposer && index == 0 ? ( +
+ + : +
+ ) : null} +
+ + {memoComponent} +
+
+
+ ); +}; + +export default TransferOperation; From 118b517bb78764fb21cbf95711b2f732c1d57c13 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Fri, 15 Mar 2019 19:30:52 +0200 Subject: [PATCH 02/12] move more operations to separate components --- .../Blockchain/ProposedOperation.jsx | 632 ++++-------------- .../Blockchain/operations/AccountCreate.jsx | 27 + .../Blockchain/operations/AccountTransfer.jsx | 15 + .../Blockchain/operations/AccountUpdate.jsx | 19 + .../Blockchain/operations/AccountUpgrade.jsx | 26 + .../operations/AccountWhitelist.jsx | 30 + .../Blockchain/operations/AssetCreate.jsx | 22 + .../operations/AssetFundFeePool.jsx | 28 + .../operations/AssetGlobalSettle.jsx | 28 + .../Blockchain/operations/AssetIssue.jsx | 38 ++ .../operations/AssetPublishFeed.jsx | 22 + .../Blockchain/operations/AssetReserve.jsx | 24 + .../Blockchain/operations/AssetSettle.jsx | 26 + .../Blockchain/operations/AssetUpdate.jsx | 24 + .../operations/AssetUpdateFeedProducers.jsx | 24 + .../Blockchain/operations/CallOrderUpdate.jsx | 36 + .../Blockchain/operations/KeyCreate.jsx | 10 + .../operations/LimitOrderCancel.jsx | 16 + .../operations/LimitOrderCreate.jsx | 45 ++ .../Blockchain/operations/ProposalCreate.jsx | 10 + .../Blockchain/operations/ProposalDelete.jsx | 10 + .../Blockchain/operations/ProposalUpdate.jsx | 10 + .../operations/ShortOrderCancel.jsx | 14 + .../Blockchain/operations/Transfer.jsx | 4 +- .../operations/WithdrawPermissionClaim.jsx | 18 + .../operations/WithdrawPermissionCreate.jsx | 18 + .../operations/WithdrawPermissionDelete.jsx | 18 + .../operations/WithdrawPermissionUpdate.jsx | 18 + .../Blockchain/operations/WitnessCreate.jsx | 12 + .../Blockchain/operations/WitnessUpdate.jsx | 12 + .../operations/WitnessWithdrawPay.jsx | 37 + app/components/Blockchain/operations/index.js | 30 + 32 files changed, 795 insertions(+), 508 deletions(-) create mode 100644 app/components/Blockchain/operations/AccountCreate.jsx create mode 100644 app/components/Blockchain/operations/AccountTransfer.jsx create mode 100644 app/components/Blockchain/operations/AccountUpdate.jsx create mode 100644 app/components/Blockchain/operations/AccountUpgrade.jsx create mode 100644 app/components/Blockchain/operations/AccountWhitelist.jsx create mode 100644 app/components/Blockchain/operations/AssetCreate.jsx create mode 100644 app/components/Blockchain/operations/AssetFundFeePool.jsx create mode 100644 app/components/Blockchain/operations/AssetGlobalSettle.jsx create mode 100644 app/components/Blockchain/operations/AssetIssue.jsx create mode 100644 app/components/Blockchain/operations/AssetPublishFeed.jsx create mode 100644 app/components/Blockchain/operations/AssetReserve.jsx create mode 100644 app/components/Blockchain/operations/AssetSettle.jsx create mode 100644 app/components/Blockchain/operations/AssetUpdate.jsx create mode 100644 app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx create mode 100644 app/components/Blockchain/operations/CallOrderUpdate.jsx create mode 100644 app/components/Blockchain/operations/KeyCreate.jsx create mode 100644 app/components/Blockchain/operations/LimitOrderCancel.jsx create mode 100644 app/components/Blockchain/operations/LimitOrderCreate.jsx create mode 100644 app/components/Blockchain/operations/ProposalCreate.jsx create mode 100644 app/components/Blockchain/operations/ProposalDelete.jsx create mode 100644 app/components/Blockchain/operations/ProposalUpdate.jsx create mode 100644 app/components/Blockchain/operations/ShortOrderCancel.jsx create mode 100644 app/components/Blockchain/operations/WithdrawPermissionClaim.jsx create mode 100644 app/components/Blockchain/operations/WithdrawPermissionCreate.jsx create mode 100644 app/components/Blockchain/operations/WithdrawPermissionDelete.jsx create mode 100644 app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx create mode 100644 app/components/Blockchain/operations/WitnessCreate.jsx create mode 100644 app/components/Blockchain/operations/WitnessUpdate.jsx create mode 100644 app/components/Blockchain/operations/WitnessWithdrawPay.jsx create mode 100644 app/components/Blockchain/operations/index.js diff --git a/app/components/Blockchain/ProposedOperation.jsx b/app/components/Blockchain/ProposedOperation.jsx index de144e1e25..d2b1924211 100644 --- a/app/components/Blockchain/ProposedOperation.jsx +++ b/app/components/Blockchain/ProposedOperation.jsx @@ -16,7 +16,38 @@ import MemoText from "./MemoText"; import TranslateWithLinks from "../Utility/TranslateWithLinks"; const {operations} = grapheneChainTypes; import PropTypes from "prop-types"; -import TransferOperation from "./operations/Transfer"; +import { + Transfer, + LimitOrderCreate, + LimitOrderCancel, + ShortOrderCancel, + CallOrderUpdate, + KeyCreate, + AccountCreate, + AccountUpdate, + AccountWhitelist, + AccountUpgrade, + AccountTransfer, + AssetCreate, + AssetUpdate, + AssetUpdateFeedProducers, + AssetIssue, + AssetReserve, + AssetFundFeePool, + AssetSettle, + AssetGlobalSettle, + AssetPublishFeed, + WitnessCreate, + WitnessUpdate, + WitnessWithdrawPay, + ProposalCreate, + ProposalUpdate, + ProposalDelete, + WithdrawPermissionCreate, + WithdrawPermissionUpdate, + WithdrawPermissionClaim, + WithdrawPermissionDelete +} from "./operations"; require("./operations.scss"); @@ -111,10 +142,6 @@ class ProposedOperation extends React.Component { csvExportMode: PropTypes.bool }; - // shouldComponentUpdate(nextProps) { - // return utils.are_equal_shallow(nextProps.op, this.props.op); - // } - linkToAccount(name_or_id) { if (!name_or_id) return -; return utils.is_object_id(name_or_id) ? ( @@ -136,7 +163,6 @@ class ProposedOperation extends React.Component { changeColor = newColor => { const {label_color} = this.state; if (label_color !== newColor) { - console.log("!!!! change color", newColor); this.setState({label_color: newColor}); } }; @@ -152,633 +178,229 @@ class ProposedOperation extends React.Component { ) { case "transfer": column = ( - + ); break; case "limit_order_create": - color = "warning"; - - let isAsk = market_utils.isAskOp(op[1]); - column = ( - - - + ); break; case "limit_order_cancel": - color = "cancel"; column = ( - - {this.linkToAccount(op[1].fee_paying_account)} -   - -  # - {op[1].order.substring(4)} - + ); break; case "short_order_cancel": - color = "cancel"; column = ( - - -   - {op[1].order} - + ); break; case "call_order_update": - color = "warning"; column = ( - - - + ); break; case "key_create": - column = ( - - - - ); + column = ; break; case "account_create": - if (current === op[1].registrar) { - column = ( - - -   - {this.linkToAccount(op[1].name)} - - ); - } else { - column = ( - - {this.linkToAccount(op[1].name)} -   - -   - {this.linkToAccount(op[1].registrar)} - - ); - } - break; - - case "account_update": column = ( - - - + ); + break; + case "account_update": + column = ; break; case "account_whitelist": - let label = - op[1].new_listing === listings.no_listing - ? "unlisted_by" - : op[1].new_listing === listings.white_listed - ? "whitelisted_by" - : "blacklisted_by"; - column = ( - - - {({lister, listee}) => ( - - )} - - - ); + column = ; break; case "account_upgrade": - if (op[1].upgrade_to_lifetime_member) { - column = ( - - {this.linkToAccount(op[1].account_to_upgrade)}{" "} -   - - - ); - } else { - column = ( - - {this.linkToAccount(op[1].account_to_upgrade)}{" "} -   - - - ); - } + column = ( + + ); break; case "account_transfer": column = ( - - -   - {this.linkToAccount(op[1].account_id)} - -   - {this.linkToAccount(op[1].new_owner)} - + ); break; case "asset_create": - color = "warning"; column = ( - ); break; case "asset_update": case "asset_update_bitasset": - color = "warning"; column = ( - ); break; case "asset_update_feed_producers": - color = "warning"; column = ( - ); break; case "asset_issue": - color = "warning"; - - if (op[1].memo) { - memoComponent = ; - } - - op[1].asset_to_issue.amount = parseInt( - op[1].asset_to_issue.amount, - 10 - ); column = ( - - - {memoComponent} - + ); break; case "asset_reserve": - column = ( - - - - ); + column = ; break; case "asset_fund_fee_pool": - color = "warning"; - let asset = ChainStore.getAsset(op[1].asset_id); - if (asset) asset = asset.get("symbol"); - else asset = op[1].asset_id; column = ( - - {this.linkToAccount(op[1].from_account)}   - -   - - + ); break; case "asset_settle": - color = "warning"; column = ( - - - + ); break; case "asset_global_settle": - color = "warning"; column = ( - - -   - {this.linkToAsset(op[1].asset_to_settle)} -   - -   - - + ); break; case "asset_publish_feed": - color = "warning"; column = ( - - {this.linkToAccount(op[1].publisher)} -   - -   - - + ); break; case "witness_create": column = ( - - -   - {this.linkToAccount(op[1].witness_account)} - + ); break; case "witness_update": - column = ( - - -   - {this.linkToAccount(op[1].witness_account)} - - ); - + column = ; break; case "witness_withdraw_pay": - if (current === op[1].witness_account) { - column = ( - - -   - - -   - {this.linkToAccount(op[1].witness_account)} - - ); - } else { - column = ( - - -   - - -   - {this.linkToAccount(op[1].witness_account)} - - ); - } + column = ( + + ); break; case "proposal_create": - column = ( - - - - ); + column = ; break; case "proposal_update": - column = ( - - - - ); + column = ; break; case "proposal_delete": - column = ( - - - - ); + column = ; break; case "withdraw_permission_create": column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].authorized_account)} - + ); break; case "withdraw_permission_update": column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].authorized_account)} - + ); break; case "withdraw_permission_claim": column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].withdraw_to_account)} - + ); break; case "withdraw_permission_delete": - column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].authorized_account)} - - ); + column = ; break; case "fill_order": diff --git a/app/components/Blockchain/operations/AccountCreate.jsx b/app/components/Blockchain/operations/AccountCreate.jsx new file mode 100644 index 0000000000..7e2879d67e --- /dev/null +++ b/app/components/Blockchain/operations/AccountCreate.jsx @@ -0,0 +1,27 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const AccountCreate = ({op, current, linkToAccount}) => { + if (current === op[1].registrar) { + return ( + + +   + {linkToAccount(op[1].name)} + + ); + } else { + return ( + + {linkToAccount(op[1].name)} +   + +   + {linkToAccount(op[1].registrar)} + + ); + } +}; diff --git a/app/components/Blockchain/operations/AccountTransfer.jsx b/app/components/Blockchain/operations/AccountTransfer.jsx new file mode 100644 index 0000000000..a50528c73e --- /dev/null +++ b/app/components/Blockchain/operations/AccountTransfer.jsx @@ -0,0 +1,15 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const AccountTransfer = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].account_id)} + +   + {linkToAccount(op[1].new_owner)} + + ); +}; diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx new file mode 100644 index 0000000000..27e11cc7c6 --- /dev/null +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -0,0 +1,19 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AccountUpdate = ({op}) => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/AccountUpgrade.jsx b/app/components/Blockchain/operations/AccountUpgrade.jsx new file mode 100644 index 0000000000..c03a8ad139 --- /dev/null +++ b/app/components/Blockchain/operations/AccountUpgrade.jsx @@ -0,0 +1,26 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const AccountUpgrade = ({op, linkToAccount}) => { + if (op[1].upgrade_to_lifetime_member) { + return ( + + {linkToAccount(op[1].account_to_upgrade)}   + + + ); + } else { + return ( + + {linkToAccount(op[1].account_to_upgrade)}   + + + ); + } +}; diff --git a/app/components/Blockchain/operations/AccountWhitelist.jsx b/app/components/Blockchain/operations/AccountWhitelist.jsx new file mode 100644 index 0000000000..01e535faec --- /dev/null +++ b/app/components/Blockchain/operations/AccountWhitelist.jsx @@ -0,0 +1,30 @@ +import React from "react"; +import Translate from "react-translate-component"; +import BindToChainState from "../../Utility/BindToChainState"; + +export const AccountWhitelist = ({op}) => { + let label = + op[1].new_listing === listings.no_listing + ? "unlisted_by" + : op[1].new_listing === listings.white_listed + ? "whitelisted_by" + : "blacklisted_by"; + + return ( + + + {({lister, listee}) => ( + + )} + + + ); +}; diff --git a/app/components/Blockchain/operations/AssetCreate.jsx b/app/components/Blockchain/operations/AssetCreate.jsx new file mode 100644 index 0000000000..562d6d139d --- /dev/null +++ b/app/components/Blockchain/operations/AssetCreate.jsx @@ -0,0 +1,22 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetCreate = ({op, changeColor}) => { + changeColor("warning"); + + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/AssetFundFeePool.jsx b/app/components/Blockchain/operations/AssetFundFeePool.jsx new file mode 100644 index 0000000000..bea233099b --- /dev/null +++ b/app/components/Blockchain/operations/AssetFundFeePool.jsx @@ -0,0 +1,28 @@ +import React from "react"; +import Translate from "react-translate-component"; +import {ChainStore} from "bitsharesjs"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const AssetFundFeePool = ({op, changeColor, linkToAccount}) => { + changeColor("warning"); + + let asset = ChainStore.getAsset(op[1].asset_id); + if (asset) asset = asset.get("symbol"); + else asset = op[1].asset_id; + return ( + + {linkToAccount(op[1].from_account)}   + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/AssetGlobalSettle.jsx b/app/components/Blockchain/operations/AssetGlobalSettle.jsx new file mode 100644 index 0000000000..5a1e9a1f0a --- /dev/null +++ b/app/components/Blockchain/operations/AssetGlobalSettle.jsx @@ -0,0 +1,28 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedPrice from "../../Utility/FormattedPrice"; + +export const AssetGlobalSettle = ({op, changeColor}) => { + changeColor("warning"); + + return ( + + +   + {this.linkToAsset(op[1].asset_to_settle)} +   + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/AssetIssue.jsx b/app/components/Blockchain/operations/AssetIssue.jsx new file mode 100644 index 0000000000..bf61dbfb5d --- /dev/null +++ b/app/components/Blockchain/operations/AssetIssue.jsx @@ -0,0 +1,38 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; +import MemoText from "../MemoText"; + +export const AssetIssue = ({op, changeColor}) => { + changeColor("warning"); + let memoComponent; + if (op[1].memo) { + memoComponent = ; + } + + op[1].asset_to_issue.amount = parseInt(op[1].asset_to_issue.amount, 10); + return ( + + + {memoComponent} + + ); +}; diff --git a/app/components/Blockchain/operations/AssetPublishFeed.jsx b/app/components/Blockchain/operations/AssetPublishFeed.jsx new file mode 100644 index 0000000000..bd5d00809e --- /dev/null +++ b/app/components/Blockchain/operations/AssetPublishFeed.jsx @@ -0,0 +1,22 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedPrice from "../../Utility/FormattedPrice"; + +export const AssetPublishFeed = ({op, changeColor, linkToAccount}) => { + changeColor("warning"); + + return ( + + {linkToAccount(op[1].publisher)} +   + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/AssetReserve.jsx b/app/components/Blockchain/operations/AssetReserve.jsx new file mode 100644 index 0000000000..ecd20b4fd1 --- /dev/null +++ b/app/components/Blockchain/operations/AssetReserve.jsx @@ -0,0 +1,24 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetReserve = ({op}) => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/AssetSettle.jsx b/app/components/Blockchain/operations/AssetSettle.jsx new file mode 100644 index 0000000000..bb57e772b8 --- /dev/null +++ b/app/components/Blockchain/operations/AssetSettle.jsx @@ -0,0 +1,26 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetSettle = ({op, changeColor}) => { + changeColor("warning"); + + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/AssetUpdate.jsx b/app/components/Blockchain/operations/AssetUpdate.jsx new file mode 100644 index 0000000000..534f42e06d --- /dev/null +++ b/app/components/Blockchain/operations/AssetUpdate.jsx @@ -0,0 +1,24 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetUpdate = ({op, changeColor}) => { + changeColor("warning"); + + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx b/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx new file mode 100644 index 0000000000..c2dfc3f4d1 --- /dev/null +++ b/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx @@ -0,0 +1,24 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetUpdateFeedProducers = ({op, changeColor}) => { + changeColor("warning"); + + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/CallOrderUpdate.jsx b/app/components/Blockchain/operations/CallOrderUpdate.jsx new file mode 100644 index 0000000000..9e1f34de86 --- /dev/null +++ b/app/components/Blockchain/operations/CallOrderUpdate.jsx @@ -0,0 +1,36 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const CallOrderUpdate = ({op, changeColor}) => { + changeColor("warning"); + + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/KeyCreate.jsx b/app/components/Blockchain/operations/KeyCreate.jsx new file mode 100644 index 0000000000..658dea7797 --- /dev/null +++ b/app/components/Blockchain/operations/KeyCreate.jsx @@ -0,0 +1,10 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const KeyCreate = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/LimitOrderCancel.jsx b/app/components/Blockchain/operations/LimitOrderCancel.jsx new file mode 100644 index 0000000000..695d58ed6b --- /dev/null +++ b/app/components/Blockchain/operations/LimitOrderCancel.jsx @@ -0,0 +1,16 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const LimitOrderCancel = ({op, changeColor}) => { + changeColor("cancel"); + + return ( + + {this.linkToAccount(op[1].fee_paying_account)} +   + +  # + {op[1].order.substring(4)} + + ); +}; diff --git a/app/components/Blockchain/operations/LimitOrderCreate.jsx b/app/components/Blockchain/operations/LimitOrderCreate.jsx new file mode 100644 index 0000000000..1c0d643228 --- /dev/null +++ b/app/components/Blockchain/operations/LimitOrderCreate.jsx @@ -0,0 +1,45 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const LimitOrderCreate = ({op, changeColor}) => { + changeColor("warning"); + let isAsk = market_utils.isAskOp(op[1]); + + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/ProposalCreate.jsx b/app/components/Blockchain/operations/ProposalCreate.jsx new file mode 100644 index 0000000000..63926e2786 --- /dev/null +++ b/app/components/Blockchain/operations/ProposalCreate.jsx @@ -0,0 +1,10 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const ProposalCreate = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/ProposalDelete.jsx b/app/components/Blockchain/operations/ProposalDelete.jsx new file mode 100644 index 0000000000..f624b6a01d --- /dev/null +++ b/app/components/Blockchain/operations/ProposalDelete.jsx @@ -0,0 +1,10 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const ProposalDelete = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/ProposalUpdate.jsx b/app/components/Blockchain/operations/ProposalUpdate.jsx new file mode 100644 index 0000000000..c2bc35c340 --- /dev/null +++ b/app/components/Blockchain/operations/ProposalUpdate.jsx @@ -0,0 +1,10 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const ProposalUpdate = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/ShortOrderCancel.jsx b/app/components/Blockchain/operations/ShortOrderCancel.jsx new file mode 100644 index 0000000000..831d625820 --- /dev/null +++ b/app/components/Blockchain/operations/ShortOrderCancel.jsx @@ -0,0 +1,14 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const ShortOrderCancel = ({op, changeColor}) => { + changeColor("cancel"); + + return ( + + +   + {op[1].order} + + ); +}; diff --git a/app/components/Blockchain/operations/Transfer.jsx b/app/components/Blockchain/operations/Transfer.jsx index 12f401decd..d84a67b38f 100644 --- a/app/components/Blockchain/operations/Transfer.jsx +++ b/app/components/Blockchain/operations/Transfer.jsx @@ -2,7 +2,7 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; import MemoText from "../MemoText"; -const TransferOperation = ({op, proposer, index, changeColor}) => { +export const Transfer = ({op, proposer, index, changeColor}) => { changeColor("success"); let memoComponent = null; @@ -56,5 +56,3 @@ const TransferOperation = ({op, proposer, index, changeColor}) => { ); }; - -export default TransferOperation; diff --git a/app/components/Blockchain/operations/WithdrawPermissionClaim.jsx b/app/components/Blockchain/operations/WithdrawPermissionClaim.jsx new file mode 100644 index 0000000000..b20cb34904 --- /dev/null +++ b/app/components/Blockchain/operations/WithdrawPermissionClaim.jsx @@ -0,0 +1,18 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const WithdrawPermissionClaim = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].withdraw_to_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx b/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx new file mode 100644 index 0000000000..201a345b36 --- /dev/null +++ b/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx @@ -0,0 +1,18 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const WithdrawPermissionCreate = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx b/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx new file mode 100644 index 0000000000..c74f44306b --- /dev/null +++ b/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx @@ -0,0 +1,18 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const WithdrawPermissionDelete = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx b/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx new file mode 100644 index 0000000000..a45ccdb9f4 --- /dev/null +++ b/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx @@ -0,0 +1,18 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const WithdrawPermissionUpdate = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/WitnessCreate.jsx b/app/components/Blockchain/operations/WitnessCreate.jsx new file mode 100644 index 0000000000..3df6a1ab31 --- /dev/null +++ b/app/components/Blockchain/operations/WitnessCreate.jsx @@ -0,0 +1,12 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const WitnessCreate = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].witness_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/WitnessUpdate.jsx b/app/components/Blockchain/operations/WitnessUpdate.jsx new file mode 100644 index 0000000000..45d1fb8797 --- /dev/null +++ b/app/components/Blockchain/operations/WitnessUpdate.jsx @@ -0,0 +1,12 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const WitnessUpdate = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].witness_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/WitnessWithdrawPay.jsx b/app/components/Blockchain/operations/WitnessWithdrawPay.jsx new file mode 100644 index 0000000000..c4f02ef5a5 --- /dev/null +++ b/app/components/Blockchain/operations/WitnessWithdrawPay.jsx @@ -0,0 +1,37 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const WitnessWithdrawPay = ({op, current, linkToAccount}) => { + if (current === op[1].witness_account) { + return ( + + +   + + +   + {linkToAccount(op[1].witness_account)} + + ); + } else { + return ( + + +   + + +   + {linkToAccount(op[1].witness_account)} + + ); + } +}; diff --git a/app/components/Blockchain/operations/index.js b/app/components/Blockchain/operations/index.js new file mode 100644 index 0000000000..0c2343088a --- /dev/null +++ b/app/components/Blockchain/operations/index.js @@ -0,0 +1,30 @@ +export {Transfer} from "./Transfer"; +export {LimitOrderCreate} from "./LimitOrderCreate"; +export {LimitOrderCancel} from "./LimitOrderCancel"; +export {ShortOrderCancel} from "./ShortOrderCancel"; +export {CallOrderUpdate} from "./CallOrderUpdate"; +export {KeyCreate} from "./KeyCreate"; +export {AccountCreate} from "./AccountCreate"; +export {AccountUpdate} from "./AccountUpdate"; +export {AccountWhitelist} from "./AccountWhitelist"; +export {AccountUpgrade} from "./AccountUpgrade"; +export {AccountTransfer} from "./AccountTransfer"; +export {AssetCreate} from "./AssetCreate"; +export {AssetUpdate} from "./AssetUpdate"; +export {AssetUpdateFeedProducers} from "./AssetUpdateFeedProducers"; +export {AssetIssue} from "./AssetIssue"; +export {AssetReserve} from "./AssetReserve"; +export {AssetFundFeePool} from "./AssetFundFeePool"; +export {AssetSettle} from "./AssetSettle"; +export {AssetGlobalSettle} from "./AssetGlobalSettle"; +export {AssetPublishFeed} from "./AssetPublishFeed"; +export {WitnessCreate} from "./WitnessCreate"; +export {WitnessUpdate} from "./WitnessUpdate"; +export {WitnessWithdrawPay} from "./WitnessWithdrawPay"; +export {ProposalCreate} from "./ProposalCreate"; +export {ProposalUpdate} from "./ProposalUpdate"; +export {ProposalDelete} from "./ProposalDelete"; +export {WithdrawPermissionCreate} from "./WithdrawPermissionCreate"; +export {WithdrawPermissionUpdate} from "./WithdrawPermissionUpdate"; +export {WithdrawPermissionClaim} from "./WithdrawPermissionClaim"; +export {WithdrawPermissionDelete} from "./WithdrawPermissionDelete"; From 6849dfd71dba0aa724cb7cc167ad3af4723f52a3 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Mon, 18 Mar 2019 12:31:44 +0200 Subject: [PATCH 03/12] finish refactoring operations to separate components --- .../Blockchain/ProposedOperation.jsx | 419 ++++-------------- .../Blockchain/operations/AssetClaimFees.jsx | 34 ++ .../Blockchain/operations/BalanceClaim.jsx | 29 ++ .../Blockchain/operations/BondAcceptOffer.jsx | 45 ++ .../Blockchain/operations/BondCancelOffer.jsx | 12 + .../operations/BondClaimCollaterial.jsx | 45 ++ .../Blockchain/operations/BondCreateOffer.jsx | 17 + .../CommitteeMemberUpdateGlobalParams.jsx | 19 + .../operations/CommittyMemberCreate.jsx | 15 + .../Blockchain/operations/Custom.jsx | 10 + .../operations/DefaultOperation.jsx | 11 + .../Blockchain/operations/FileWrite.jsx | 10 + .../Blockchain/operations/FillOrder.jsx | 39 ++ .../operations/GlobalParametersUpdate.jsx | 13 + .../operations/OverrideTransfer.jsx | 20 + .../operations/TransferFromBlind.jsx | 19 + .../Blockchain/operations/TransferToBlind.jsx | 19 + .../operations/VestingBalanceCreate.jsx | 24 + .../operations/VestingBalanceWithdraw.jsx | 18 + .../Blockchain/operations/WorkerCreate.jsx | 17 + app/components/Blockchain/operations/index.js | 21 + 21 files changed, 518 insertions(+), 338 deletions(-) create mode 100644 app/components/Blockchain/operations/AssetClaimFees.jsx create mode 100644 app/components/Blockchain/operations/BalanceClaim.jsx create mode 100644 app/components/Blockchain/operations/BondAcceptOffer.jsx create mode 100644 app/components/Blockchain/operations/BondCancelOffer.jsx create mode 100644 app/components/Blockchain/operations/BondClaimCollaterial.jsx create mode 100644 app/components/Blockchain/operations/BondCreateOffer.jsx create mode 100644 app/components/Blockchain/operations/CommitteeMemberUpdateGlobalParams.jsx create mode 100644 app/components/Blockchain/operations/CommittyMemberCreate.jsx create mode 100644 app/components/Blockchain/operations/Custom.jsx create mode 100644 app/components/Blockchain/operations/DefaultOperation.jsx create mode 100644 app/components/Blockchain/operations/FileWrite.jsx create mode 100644 app/components/Blockchain/operations/FillOrder.jsx create mode 100644 app/components/Blockchain/operations/GlobalParametersUpdate.jsx create mode 100644 app/components/Blockchain/operations/OverrideTransfer.jsx create mode 100644 app/components/Blockchain/operations/TransferFromBlind.jsx create mode 100644 app/components/Blockchain/operations/TransferToBlind.jsx create mode 100644 app/components/Blockchain/operations/VestingBalanceCreate.jsx create mode 100644 app/components/Blockchain/operations/VestingBalanceWithdraw.jsx create mode 100644 app/components/Blockchain/operations/WorkerCreate.jsx diff --git a/app/components/Blockchain/ProposedOperation.jsx b/app/components/Blockchain/ProposedOperation.jsx index d2b1924211..61c147ab98 100644 --- a/app/components/Blockchain/ProposedOperation.jsx +++ b/app/components/Blockchain/ProposedOperation.jsx @@ -1,19 +1,13 @@ import React from "react"; import FormattedAsset from "../Utility/FormattedAsset"; import {Link} from "react-router-dom"; -import classNames from "classnames"; import Translate from "react-translate-component"; import counterpart from "counterpart"; -import market_utils from "common/market_utils"; import utils from "common/utils"; import LinkToAccountById from "../Utility/LinkToAccountById"; import LinkToAssetById from "../Utility/LinkToAssetById"; -import BindToChainState from "../Utility/BindToChainState"; -import FormattedPrice from "../Utility/FormattedPrice"; import {ChainStore, ChainTypes as grapheneChainTypes} from "bitsharesjs"; -import account_constants from "chain/account_constants"; -import MemoText from "./MemoText"; -import TranslateWithLinks from "../Utility/TranslateWithLinks"; +// import account_constants from "chain/account_constants"; const {operations} = grapheneChainTypes; import PropTypes from "prop-types"; import { @@ -46,13 +40,32 @@ import { WithdrawPermissionCreate, WithdrawPermissionUpdate, WithdrawPermissionClaim, - WithdrawPermissionDelete + WithdrawPermissionDelete, + FillOrder, + GlobalParametersUpdate, + FileWrite, + VestingBalanceCreate, + VestingBalanceWithdraw, + BondCreateOffer, + BondCancelOffer, + BondAcceptOffer, + BondClaimCollaterial, + WorkerCreate, + BalanceClaim, + CommittyMemberCreate, + TransferToBlind, + TransferFromBlind, + AssetClaimFees, + CommitteeMemberUpdateGlobalParams, + Custom, + OverrideTransfer, + DefaultOperation } from "./operations"; require("./operations.scss"); let ops = Object.keys(operations); -let listings = account_constants.account_listing; +// let listings = account_constants.account_listing; export const TransactionIDAndExpiry = ({id, expiration, style}) => { const endDate = counterpart.localize(new Date(expiration), { @@ -168,10 +181,10 @@ class ProposedOperation extends React.Component { }; render() { - let {op, proposer, current, block, hideExpiration, index} = this.props; + let {op, block, hideExpiration, index, csvExportMode} = this.props; + const {label_color} = this.state; let line = null, - column = null, - color = "info"; + column = null; switch ( ops[op[0]] // For a list of trx types, see chain_types.coffee @@ -180,7 +193,6 @@ class ProposedOperation extends React.Component { column = ( ); - break; case "limit_order_create": @@ -404,399 +416,130 @@ class ProposedOperation extends React.Component { break; case "fill_order": - color = "success"; - o = op[1]; column = ( - - {this.linkToAccount(op[1].account_id)} -   - -   - -   - -   - -   - -   - - + ); break; case "global_parameters_update": - column = ( - - - - ); + column = ; break; case "file_write": - column = ( - - - - ); + column = ; break; case "vesting_balance_create": column = ( - -   - {this.linkToAccount(op[1].creator)} - -   - -   - {this.linkToAccount(op[1].owner)} - + ); break; case "vesting_balance_withdraw": - column = ( - - ); + column = ; break; case "bond_create_offer": - column = ( - - -   - - - ); + column = ; break; case "bond_cancel_offer": - column = ( - - -   - {op[1].offer_id} - - ); + column = ; break; case "bond_accept_offer": - if (current === op[1].lender) { - column = ( - - -   - - -   - {this.linkToAccount(op[1].borrower)} - - ); - } else if (current === op[1].borrower) { - column = ( - - -   - - -   - {this.linkToAccount(op[1].lender)} - - ); - } + column = ( + + ); break; case "bond_claim_collateral": - if (current === op[1].lender) { - column = ( - - -   - - -   - {this.linkToAccount(op[1].claimer)} - - ); - } else if (current === op[1].claimer) { - column = ( - - -   - - -   - {this.linkToAccount(op[1].lender)} - - ); - } + column = ( + + ); break; case "worker_create": - column = ( - - -   - - - ); + column = ; break; case "balance_claim": - color = "success"; - op[1].total_claimed.amount = parseInt( - op[1].total_claimed.amount, - 10 - ); column = ( - - {this.linkToAccount(op[1].deposit_to_account)} -   - - {({asset}) => ( - - )} - - + ); break; case "committee_member_create": column = ( - - -   - {this.linkToAccount(op[1].committee_member_account)} - + ); break; case "transfer_to_blind": column = ( - - {this.linkToAccount(op[1].from)} -   - -   - - + ); break; case "transfer_from_blind": column = ( - - {this.linkToAccount(op[1].to)} -   - -   - - + ); break; case "asset_claim_fees": - color = "success"; - op[1].amount_to_claim.amount = parseInt( - op[1].amount_to_claim.amount, - 10 - ); column = ( - - {this.linkToAccount(op[1].issuer)} -   - - {({asset}) => ( - - )} - - + ); break; case "committee_member_update_global_parameters": - column = ( - - - - ); + column = ; break; case "custom": - column = ( - - - - ); + column = ; break; case "override_transfer": - column = ( - - ); + column = ; break; default: - console.log("unimplemented op:", op); - column = ( - - #{block} - - ); + ; } - if (this.props.csvExportMode) { + if (csvExportMode) { const globalObject = ChainStore.getObject("2.0.0"); const dynGlobalObject = ChainStore.getObject("2.1.0"); const block_time = utils.calc_block_time( @@ -821,11 +564,11 @@ class ProposedOperation extends React.Component { line = column ? ( { + changeColor("success"); + op[1].amount_to_claim.amount = parseInt(op[1].amount_to_claim.amount, 10); + + return ( + + {linkToAccount(op[1].issuer)} +   + + {({asset}) => ( + + )} + + + ); +}; diff --git a/app/components/Blockchain/operations/BalanceClaim.jsx b/app/components/Blockchain/operations/BalanceClaim.jsx new file mode 100644 index 0000000000..2f5f3bc36d --- /dev/null +++ b/app/components/Blockchain/operations/BalanceClaim.jsx @@ -0,0 +1,29 @@ +import React from "react"; +import Translate from "react-translate-component"; +import BindToChainState from "../../Utility/BindToChainState"; +import utils from "common/utils"; + +export const BalanceClaim = ({op, changeColor, linkToAccount}) => { + changeColor("success"); + op[1].total_claimed.amount = parseInt(op[1].total_claimed.amount, 10); + + return ( + + {linkToAccount(op[1].deposit_to_account)} +   + + {({asset}) => ( + + )} + + + ); +}; diff --git a/app/components/Blockchain/operations/BondAcceptOffer.jsx b/app/components/Blockchain/operations/BondAcceptOffer.jsx new file mode 100644 index 0000000000..7d33e098a5 --- /dev/null +++ b/app/components/Blockchain/operations/BondAcceptOffer.jsx @@ -0,0 +1,45 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const BondAcceptOffer = ({op, linkToAccount}) => { + if (current === op[1].lender) { + return ( + + +   + + +   + {linkToAccount(op[1].borrower)} + + ); + } else if (current === op[1].borrower) { + return ( + + +   + + +   + {linkToAccount(op[1].lender)} + + ); + } else { + return null; + } +}; diff --git a/app/components/Blockchain/operations/BondCancelOffer.jsx b/app/components/Blockchain/operations/BondCancelOffer.jsx new file mode 100644 index 0000000000..60e0a49958 --- /dev/null +++ b/app/components/Blockchain/operations/BondCancelOffer.jsx @@ -0,0 +1,12 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const BondCancelOffer = ({op}) => { + return ( + + +   + {op[1].offer_id} + + ); +}; diff --git a/app/components/Blockchain/operations/BondClaimCollaterial.jsx b/app/components/Blockchain/operations/BondClaimCollaterial.jsx new file mode 100644 index 0000000000..fec9b5a9e9 --- /dev/null +++ b/app/components/Blockchain/operations/BondClaimCollaterial.jsx @@ -0,0 +1,45 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const BondClaimCollaterial = ({op, linkToAccount}) => { + if (current === op[1].lender) { + return ( + + +   + + +   + {linkToAccount(op[1].claimer)} + + ); + } else if (current === op[1].claimer) { + return ( + + +   + + +   + {linkToAccount(op[1].lender)} + + ); + } else { + return null; + } +}; diff --git a/app/components/Blockchain/operations/BondCreateOffer.jsx b/app/components/Blockchain/operations/BondCreateOffer.jsx new file mode 100644 index 0000000000..84c51ed7f8 --- /dev/null +++ b/app/components/Blockchain/operations/BondCreateOffer.jsx @@ -0,0 +1,17 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const BondCreateOffer = ({op}) => { + return ( + + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/CommitteeMemberUpdateGlobalParams.jsx b/app/components/Blockchain/operations/CommitteeMemberUpdateGlobalParams.jsx new file mode 100644 index 0000000000..8bca47c763 --- /dev/null +++ b/app/components/Blockchain/operations/CommitteeMemberUpdateGlobalParams.jsx @@ -0,0 +1,19 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const CommitteeMemberUpdateGlobalParams = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/CommittyMemberCreate.jsx b/app/components/Blockchain/operations/CommittyMemberCreate.jsx new file mode 100644 index 0000000000..607cda54fa --- /dev/null +++ b/app/components/Blockchain/operations/CommittyMemberCreate.jsx @@ -0,0 +1,15 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const CommittyMemberCreate = ({op, linkToAccount}) => { + return ( + + +   + {linkToAccount(op[1].committee_member_account)} + + ); +}; diff --git a/app/components/Blockchain/operations/Custom.jsx b/app/components/Blockchain/operations/Custom.jsx new file mode 100644 index 0000000000..b0883de0b4 --- /dev/null +++ b/app/components/Blockchain/operations/Custom.jsx @@ -0,0 +1,10 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const Custom = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/DefaultOperation.jsx b/app/components/Blockchain/operations/DefaultOperation.jsx new file mode 100644 index 0000000000..68f4a3bdc9 --- /dev/null +++ b/app/components/Blockchain/operations/DefaultOperation.jsx @@ -0,0 +1,11 @@ +import React from "react"; +import {Link} from "react-router-dom"; + +export const DefaultOperation = ({op, block}) => { + console.log("unimplemented op:", op); + return ( + + #{block} + + ); +}; diff --git a/app/components/Blockchain/operations/FileWrite.jsx b/app/components/Blockchain/operations/FileWrite.jsx new file mode 100644 index 0000000000..7aa8023a9b --- /dev/null +++ b/app/components/Blockchain/operations/FileWrite.jsx @@ -0,0 +1,10 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const FileWrite = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/FillOrder.jsx b/app/components/Blockchain/operations/FillOrder.jsx new file mode 100644 index 0000000000..33629e09c6 --- /dev/null +++ b/app/components/Blockchain/operations/FillOrder.jsx @@ -0,0 +1,39 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; +import FormattedPrice from "../../Utility/FormattedPrice"; + +export const FillOrder = ({changeColor, op, linkToAccount}) => { + changeColor("success"); + const o = op[1]; + return ( + + {linkToAccount(op.account_id)} +   + +   + +   + +   + +   + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/GlobalParametersUpdate.jsx b/app/components/Blockchain/operations/GlobalParametersUpdate.jsx new file mode 100644 index 0000000000..f5e2d93099 --- /dev/null +++ b/app/components/Blockchain/operations/GlobalParametersUpdate.jsx @@ -0,0 +1,13 @@ +import React from "react"; +import Translate from "react-translate-component"; + +export const GlobalParametersUpdate = () => { + return ( + + + + ); +}; diff --git a/app/components/Blockchain/operations/OverrideTransfer.jsx b/app/components/Blockchain/operations/OverrideTransfer.jsx new file mode 100644 index 0000000000..77806830e3 --- /dev/null +++ b/app/components/Blockchain/operations/OverrideTransfer.jsx @@ -0,0 +1,20 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const OverrideTransfer = ({op}) => { + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/TransferFromBlind.jsx b/app/components/Blockchain/operations/TransferFromBlind.jsx new file mode 100644 index 0000000000..4a4152559e --- /dev/null +++ b/app/components/Blockchain/operations/TransferFromBlind.jsx @@ -0,0 +1,19 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const TransferFromBlind = ({op, linkToAccount}) => { + return ( + + {linkToAccount(op[1].to)} +   + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/TransferToBlind.jsx b/app/components/Blockchain/operations/TransferToBlind.jsx new file mode 100644 index 0000000000..ab66f51e32 --- /dev/null +++ b/app/components/Blockchain/operations/TransferToBlind.jsx @@ -0,0 +1,19 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const TransferToBlind = ({op, linkToAccount}) => { + return ( + + {linkToAccount(op[1].from)} +   + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/VestingBalanceCreate.jsx b/app/components/Blockchain/operations/VestingBalanceCreate.jsx new file mode 100644 index 0000000000..1b3adf30b4 --- /dev/null +++ b/app/components/Blockchain/operations/VestingBalanceCreate.jsx @@ -0,0 +1,24 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const VestingBalanceCreate = ({op, linkToAccount}) => { + return ( + +   + {linkToAccount(op[1].creator)} + +   + +   + {linkToAccount(op[1].owner)} + + ); +}; diff --git a/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx b/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx new file mode 100644 index 0000000000..7c71d64f1c --- /dev/null +++ b/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx @@ -0,0 +1,18 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const VestingBalanceWithdraw = ({op}) => { + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/WorkerCreate.jsx b/app/components/Blockchain/operations/WorkerCreate.jsx new file mode 100644 index 0000000000..866e903374 --- /dev/null +++ b/app/components/Blockchain/operations/WorkerCreate.jsx @@ -0,0 +1,17 @@ +import React from "react"; +import Translate from "react-translate-component"; +import FormattedAsset from "../../Utility/FormattedAsset"; + +export const WorkerCreate = ({op}) => { + return ( + + +   + + + ); +}; diff --git a/app/components/Blockchain/operations/index.js b/app/components/Blockchain/operations/index.js index 0c2343088a..56855ac88a 100644 --- a/app/components/Blockchain/operations/index.js +++ b/app/components/Blockchain/operations/index.js @@ -28,3 +28,24 @@ export {WithdrawPermissionCreate} from "./WithdrawPermissionCreate"; export {WithdrawPermissionUpdate} from "./WithdrawPermissionUpdate"; export {WithdrawPermissionClaim} from "./WithdrawPermissionClaim"; export {WithdrawPermissionDelete} from "./WithdrawPermissionDelete"; +export {FillOrder} from "./FillOrder"; +export {GlobalParametersUpdate} from "./GlobalParametersUpdate"; +export {FileWrite} from "./FileWrite"; +export {VestingBalanceCreate} from "./VestingBalanceCreate"; +export {VestingBalanceWithdraw} from "./VestingBalanceWithdraw"; +export {BondCreateOffer} from "./BondCreateOffer"; +export {BondCancelOffer} from "./BondCancelOffer"; +export {BondAcceptOffer} from "./BondAcceptOffer"; +export {BondClaimCollaterial} from "./BondClaimCollaterial"; +export {WorkerCreate} from "./WorkerCreate"; +export {BalanceClaim} from "./BalanceClaim"; +export {CommittyMemberCreate} from "./CommittyMemberCreate"; +export {TransferToBlind} from "./TransferToBlind"; +export {TransferFromBlind} from "./TransferFromBlind"; +export {AssetClaimFees} from "./AssetClaimFees"; +export { + CommitteeMemberUpdateGlobalParams +} from "./CommitteeMemberUpdateGlobalParams"; +export {Custom} from "./Custom"; +export {OverrideTransfer} from "./OverrideTransfer"; +export {DefaultOperation} from "./DefaultOperation"; From ac879417a84cdb8d01309c22b6bf6d25809eef50 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Tue, 26 Mar 2019 16:27:25 +0200 Subject: [PATCH 04/12] created opComponents func --- app/components/Blockchain/Operation.jsx | 48 +- .../Blockchain/ProposedOperation.jsx | 412 +----------------- .../operations/AssetGlobalSettle.jsx | 4 +- .../Blockchain/operations/Transfer.jsx | 2 +- app/components/Blockchain/operations/index.js | 412 +++++++++++++++--- 5 files changed, 406 insertions(+), 472 deletions(-) diff --git a/app/components/Blockchain/Operation.jsx b/app/components/Blockchain/Operation.jsx index 4af6b63cae..b509600407 100644 --- a/app/components/Blockchain/Operation.jsx +++ b/app/components/Blockchain/Operation.jsx @@ -22,6 +22,7 @@ import PropTypes from "prop-types"; import {Tooltip} from "bitshares-ui-style-guide"; const {operations} = grapheneChainTypes; +import opComponents from "./operations"; require("./operations.scss"); let ops = Object.keys(operations); @@ -71,10 +72,12 @@ class Row extends React.Component { let last_irreversible_block_num = dynGlobalObject.get( "last_irreversible_block_num" ); - if (nextProps.dynGlobalObject === this.props.dynGlobalObject) { - return false; - } - return block > last_irreversible_block_num; + + return ( + nextProps.dynGlobalObject !== this.props.dynGlobalObject || + block > last_irreversible_block_num || + this.props.color !== nextProps.color + ); } render() { @@ -169,9 +172,14 @@ class Row extends React.Component { ); } } + Row = BindToChainState(Row); class Operation extends React.Component { + state = { + labelColor: "info" + }; + static defaultProps = { op: [], current: "", @@ -211,16 +219,24 @@ class Operation extends React.Component { ); } - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps, nextState) { if (!this.props.op || !nextProps.op) { return false; } return ( !utils.are_equal_shallow(nextProps.op[1], this.props.op[1]) || - nextProps.marketDirections !== this.props.marketDirections + nextProps.marketDirections !== this.props.marketDirections || + this.state.labelColor !== nextState.labelColor ); } + changeColor = newColor => { + const {labelColor} = this.state; + if (labelColor !== newColor) { + this.setState({labelColor: newColor}); + } + }; + render() { let {op, current, block} = this.props; let line = null, @@ -228,11 +244,12 @@ class Operation extends React.Component { color = "info"; let memoComponent = null; + console.log("Operation component", ops[op[0]]); switch ( ops[op[0]] // For a list of trx types, see chain_types.coffee ) { case "transfer": - if (op[1].memo) { + /* if (op[1].memo) { memoComponent = ; } @@ -252,18 +269,21 @@ class Operation extends React.Component { { type: "amount", value: op[1].amount, - arg: "amount", - decimalOffset: - op[1].amount.asset_id === "1.3.0" - ? 5 - : null + arg: "amount" + // decimalOffset: + // op[1].amount.asset_id === "1.3.0" + // ? 5 + // : null }, {type: "account", value: op[1].to, arg: "to"} ]} /> {memoComponent} - ); + ); */ + column = opComponents("transfer", this.props, { + changeColor: this.changeColor + }); break; @@ -1560,7 +1580,7 @@ class Operation extends React.Component { includeOperationId={this.props.includeOperationId} block={block} type={op[0]} - color={color} + color={this.state.labelColor} fee={op[1].fee} hideOpLabel={this.props.hideOpLabel} hideDate={this.props.hideDate} diff --git a/app/components/Blockchain/ProposedOperation.jsx b/app/components/Blockchain/ProposedOperation.jsx index 61c147ab98..5423a7a077 100644 --- a/app/components/Blockchain/ProposedOperation.jsx +++ b/app/components/Blockchain/ProposedOperation.jsx @@ -10,57 +10,7 @@ import {ChainStore, ChainTypes as grapheneChainTypes} from "bitsharesjs"; // import account_constants from "chain/account_constants"; const {operations} = grapheneChainTypes; import PropTypes from "prop-types"; -import { - Transfer, - LimitOrderCreate, - LimitOrderCancel, - ShortOrderCancel, - CallOrderUpdate, - KeyCreate, - AccountCreate, - AccountUpdate, - AccountWhitelist, - AccountUpgrade, - AccountTransfer, - AssetCreate, - AssetUpdate, - AssetUpdateFeedProducers, - AssetIssue, - AssetReserve, - AssetFundFeePool, - AssetSettle, - AssetGlobalSettle, - AssetPublishFeed, - WitnessCreate, - WitnessUpdate, - WitnessWithdrawPay, - ProposalCreate, - ProposalUpdate, - ProposalDelete, - WithdrawPermissionCreate, - WithdrawPermissionUpdate, - WithdrawPermissionClaim, - WithdrawPermissionDelete, - FillOrder, - GlobalParametersUpdate, - FileWrite, - VestingBalanceCreate, - VestingBalanceWithdraw, - BondCreateOffer, - BondCancelOffer, - BondAcceptOffer, - BondClaimCollaterial, - WorkerCreate, - BalanceClaim, - CommittyMemberCreate, - TransferToBlind, - TransferFromBlind, - AssetClaimFees, - CommitteeMemberUpdateGlobalParams, - Custom, - OverrideTransfer, - DefaultOperation -} from "./operations"; +import opComponents from "./operations"; require("./operations.scss"); @@ -180,364 +130,18 @@ class ProposedOperation extends React.Component { } }; + // TODO: add scu + render() { let {op, block, hideExpiration, index, csvExportMode} = this.props; const {label_color} = this.state; let line = null, column = null; - - switch ( - ops[op[0]] // For a list of trx types, see chain_types.coffee - ) { - case "transfer": - column = ( - - ); - break; - - case "limit_order_create": - column = ( - - ); - break; - - case "limit_order_cancel": - column = ( - - ); - break; - - case "short_order_cancel": - column = ( - - ); - break; - - case "call_order_update": - column = ( - - ); - break; - - case "key_create": - column = ; - break; - - case "account_create": - column = ( - - ); - break; - - case "account_update": - column = ; - break; - - case "account_whitelist": - column = ; - break; - - case "account_upgrade": - column = ( - - ); - break; - - case "account_transfer": - column = ( - - ); - break; - - case "asset_create": - column = ( - - ); - break; - - case "asset_update": - case "asset_update_bitasset": - column = ( - - ); - break; - - case "asset_update_feed_producers": - column = ( - - ); - break; - - case "asset_issue": - column = ( - - ); - break; - - case "asset_reserve": - column = ; - break; - - case "asset_fund_fee_pool": - column = ( - - ); - break; - - case "asset_settle": - column = ( - - ); - break; - - case "asset_global_settle": - column = ( - - ); - break; - - case "asset_publish_feed": - column = ( - - ); - break; - - case "witness_create": - column = ( - - ); - - break; - - case "witness_update": - column = ; - break; - - case "witness_withdraw_pay": - column = ( - - ); - break; - - case "proposal_create": - column = ; - break; - - case "proposal_update": - column = ; - break; - - case "proposal_delete": - column = ; - break; - - case "withdraw_permission_create": - column = ( - - ); - break; - - case "withdraw_permission_update": - column = ( - - ); - break; - - case "withdraw_permission_claim": - column = ( - - ); - break; - - case "withdraw_permission_delete": - column = ; - break; - - case "fill_order": - column = ( - - ); - break; - - case "global_parameters_update": - column = ; - break; - - case "file_write": - column = ; - break; - - case "vesting_balance_create": - column = ( - - ); - break; - - case "vesting_balance_withdraw": - column = ; - break; - - case "bond_create_offer": - column = ; - break; - - case "bond_cancel_offer": - column = ; - break; - - case "bond_accept_offer": - column = ( - - ); - break; - - case "bond_claim_collateral": - column = ( - - ); - break; - - case "worker_create": - column = ; - break; - - case "balance_claim": - column = ( - - ); - break; - - case "committee_member_create": - column = ( - - ); - break; - - case "transfer_to_blind": - column = ( - - ); - break; - - case "transfer_from_blind": - column = ( - - ); - break; - - case "asset_claim_fees": - column = ( - - ); - break; - - case "committee_member_update_global_parameters": - column = ; - break; - - case "custom": - column = ; - break; - - case "override_transfer": - column = ; - break; - - default: - ; - } + column = opComponents(ops[op[0]], this.props, { + linkToAccount: this.linkToAccount, + linkToAsset: this.linkToAsset, + changeColor: this.changeColor + }); if (csvExportMode) { const globalObject = ChainStore.getObject("2.0.0"); diff --git a/app/components/Blockchain/operations/AssetGlobalSettle.jsx b/app/components/Blockchain/operations/AssetGlobalSettle.jsx index 5a1e9a1f0a..c68d874d5b 100644 --- a/app/components/Blockchain/operations/AssetGlobalSettle.jsx +++ b/app/components/Blockchain/operations/AssetGlobalSettle.jsx @@ -2,7 +2,7 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedPrice from "../../Utility/FormattedPrice"; -export const AssetGlobalSettle = ({op, changeColor}) => { +export const AssetGlobalSettle = ({op, changeColor, linkToAsset}) => { changeColor("warning"); return ( @@ -12,7 +12,7 @@ export const AssetGlobalSettle = ({op, changeColor}) => { content="proposal.asset_global_settle" />   - {this.linkToAsset(op[1].asset_to_settle)} + {linkToAsset(op[1].asset_to_settle)}     diff --git a/app/components/Blockchain/operations/Transfer.jsx b/app/components/Blockchain/operations/Transfer.jsx index d84a67b38f..91f67fe3e5 100644 --- a/app/components/Blockchain/operations/Transfer.jsx +++ b/app/components/Blockchain/operations/Transfer.jsx @@ -3,7 +3,7 @@ import TranslateWithLinks from "../../Utility/TranslateWithLinks"; import MemoText from "../MemoText"; export const Transfer = ({op, proposer, index, changeColor}) => { - changeColor("success"); + changeColor("success"); // color of label let memoComponent = null; if (op[1].memo) { diff --git a/app/components/Blockchain/operations/index.js b/app/components/Blockchain/operations/index.js index 56855ac88a..ceef9a9662 100644 --- a/app/components/Blockchain/operations/index.js +++ b/app/components/Blockchain/operations/index.js @@ -1,51 +1,361 @@ -export {Transfer} from "./Transfer"; -export {LimitOrderCreate} from "./LimitOrderCreate"; -export {LimitOrderCancel} from "./LimitOrderCancel"; -export {ShortOrderCancel} from "./ShortOrderCancel"; -export {CallOrderUpdate} from "./CallOrderUpdate"; -export {KeyCreate} from "./KeyCreate"; -export {AccountCreate} from "./AccountCreate"; -export {AccountUpdate} from "./AccountUpdate"; -export {AccountWhitelist} from "./AccountWhitelist"; -export {AccountUpgrade} from "./AccountUpgrade"; -export {AccountTransfer} from "./AccountTransfer"; -export {AssetCreate} from "./AssetCreate"; -export {AssetUpdate} from "./AssetUpdate"; -export {AssetUpdateFeedProducers} from "./AssetUpdateFeedProducers"; -export {AssetIssue} from "./AssetIssue"; -export {AssetReserve} from "./AssetReserve"; -export {AssetFundFeePool} from "./AssetFundFeePool"; -export {AssetSettle} from "./AssetSettle"; -export {AssetGlobalSettle} from "./AssetGlobalSettle"; -export {AssetPublishFeed} from "./AssetPublishFeed"; -export {WitnessCreate} from "./WitnessCreate"; -export {WitnessUpdate} from "./WitnessUpdate"; -export {WitnessWithdrawPay} from "./WitnessWithdrawPay"; -export {ProposalCreate} from "./ProposalCreate"; -export {ProposalUpdate} from "./ProposalUpdate"; -export {ProposalDelete} from "./ProposalDelete"; -export {WithdrawPermissionCreate} from "./WithdrawPermissionCreate"; -export {WithdrawPermissionUpdate} from "./WithdrawPermissionUpdate"; -export {WithdrawPermissionClaim} from "./WithdrawPermissionClaim"; -export {WithdrawPermissionDelete} from "./WithdrawPermissionDelete"; -export {FillOrder} from "./FillOrder"; -export {GlobalParametersUpdate} from "./GlobalParametersUpdate"; -export {FileWrite} from "./FileWrite"; -export {VestingBalanceCreate} from "./VestingBalanceCreate"; -export {VestingBalanceWithdraw} from "./VestingBalanceWithdraw"; -export {BondCreateOffer} from "./BondCreateOffer"; -export {BondCancelOffer} from "./BondCancelOffer"; -export {BondAcceptOffer} from "./BondAcceptOffer"; -export {BondClaimCollaterial} from "./BondClaimCollaterial"; -export {WorkerCreate} from "./WorkerCreate"; -export {BalanceClaim} from "./BalanceClaim"; -export {CommittyMemberCreate} from "./CommittyMemberCreate"; -export {TransferToBlind} from "./TransferToBlind"; -export {TransferFromBlind} from "./TransferFromBlind"; -export {AssetClaimFees} from "./AssetClaimFees"; -export { - CommitteeMemberUpdateGlobalParams -} from "./CommitteeMemberUpdateGlobalParams"; -export {Custom} from "./Custom"; -export {OverrideTransfer} from "./OverrideTransfer"; -export {DefaultOperation} from "./DefaultOperation"; +import React from "react"; +import {Transfer} from "./Transfer"; +import {LimitOrderCreate} from "./LimitOrderCreate"; +import {LimitOrderCancel} from "./LimitOrderCancel"; +import {ShortOrderCancel} from "./ShortOrderCancel"; +import {CallOrderUpdate} from "./CallOrderUpdate"; +import {KeyCreate} from "./KeyCreate"; +import {AccountCreate} from "./AccountCreate"; +import {AccountUpdate} from "./AccountUpdate"; +import {AccountWhitelist} from "./AccountWhitelist"; +import {AccountUpgrade} from "./AccountUpgrade"; +import {AccountTransfer} from "./AccountTransfer"; +import {AssetCreate} from "./AssetCreate"; +import {AssetUpdate} from "./AssetUpdate"; +import {AssetUpdateFeedProducers} from "./AssetUpdateFeedProducers"; +import {AssetIssue} from "./AssetIssue"; +import {AssetReserve} from "./AssetReserve"; +import {AssetFundFeePool} from "./AssetFundFeePool"; +import {AssetSettle} from "./AssetSettle"; +import {AssetGlobalSettle} from "./AssetGlobalSettle"; +import {AssetPublishFeed} from "./AssetPublishFeed"; +import {WitnessCreate} from "./WitnessCreate"; +import {WitnessUpdate} from "./WitnessUpdate"; +import {WitnessWithdrawPay} from "./WitnessWithdrawPay"; +import {ProposalCreate} from "./ProposalCreate"; +import {ProposalUpdate} from "./ProposalUpdate"; +import {ProposalDelete} from "./ProposalDelete"; +import {WithdrawPermissionCreate} from "./WithdrawPermissionCreate"; +import {WithdrawPermissionUpdate} from "./WithdrawPermissionUpdate"; +import {WithdrawPermissionClaim} from "./WithdrawPermissionClaim"; +import {WithdrawPermissionDelete} from "./WithdrawPermissionDelete"; +import {FillOrder} from "./FillOrder"; +import {GlobalParametersUpdate} from "./GlobalParametersUpdate"; +import {FileWrite} from "./FileWrite"; +import {VestingBalanceCreate} from "./VestingBalanceCreate"; +import {VestingBalanceWithdraw} from "./VestingBalanceWithdraw"; +import {BondCreateOffer} from "./BondCreateOffer"; +import {BondCancelOffer} from "./BondCancelOffer"; +import {BondAcceptOffer} from "./BondAcceptOffer"; +import {BondClaimCollaterial} from "./BondClaimCollaterial"; +import {WorkerCreate} from "./WorkerCreate"; +import {BalanceClaim} from "./BalanceClaim"; +import {CommittyMemberCreate} from "./CommittyMemberCreate"; +import {TransferToBlind} from "./TransferToBlind"; +import {TransferFromBlind} from "./TransferFromBlind"; +import {AssetClaimFees} from "./AssetClaimFees"; +import {CommitteeMemberUpdateGlobalParams} from "./CommitteeMemberUpdateGlobalParams"; +import {Custom} from "./Custom"; +import {OverrideTransfer} from "./OverrideTransfer"; +import {DefaultOperation} from "./DefaultOperation"; + +export default function opComponents(opType, props, opts) { + console.log("** operation params**", {opType, props, opts}); + + switch (opType) { + case "transfer": + return ; + break; + case "limit_order_create": + return ( + + ); + break; + case "limit_order_cancel": + column = ( + + ); + break; + + case "short_order_cancel": + column = ( + + ); + break; + + case "call_order_update": + column = ( + + ); + break; + + case "key_create": + column = ; + break; + + case "account_create": + column = ( + + ); + break; + + case "account_update": + column = ; + break; + + case "account_whitelist": + column = ; + break; + + case "account_upgrade": + column = ( + + ); + break; + + case "account_transfer": + column = ( + + ); + break; + + case "asset_create": + column = ; + break; + + case "asset_update": + case "asset_update_bitasset": + column = ; + break; + + case "asset_update_feed_producers": + column = ( + + ); + break; + + case "asset_issue": + column = ; + break; + + case "asset_reserve": + column = ; + break; + + case "asset_fund_fee_pool": + column = ( + + ); + break; + + case "asset_settle": + column = ; + break; + + case "asset_global_settle": + column = ( + + ); + break; + + case "asset_publish_feed": + column = ( + + ); + break; + + case "witness_create": + column = ( + + ); + + break; + + case "witness_update": + column = ; + break; + + case "witness_withdraw_pay": + column = ( + + ); + break; + + case "proposal_create": + column = ; + break; + + case "proposal_update": + column = ; + break; + + case "proposal_delete": + column = ; + break; + + case "withdraw_permission_create": + column = ( + + ); + break; + + case "withdraw_permission_update": + column = ( + + ); + break; + + case "withdraw_permission_claim": + column = ( + + ); + break; + + case "withdraw_permission_delete": + column = ; + break; + + case "fill_order": + column = ( + + ); + break; + + case "global_parameters_update": + column = ; + break; + + case "file_write": + column = ; + break; + + case "vesting_balance_create": + column = ( + + ); + break; + + case "vesting_balance_withdraw": + column = ; + break; + + case "bond_create_offer": + column = ; + break; + + case "bond_cancel_offer": + column = ; + break; + + case "bond_accept_offer": + column = ( + + ); + break; + + case "bond_claim_collateral": + column = ( + + ); + break; + + case "worker_create": + column = ; + break; + + case "balance_claim": + column = ( + + ); + break; + + case "committee_member_create": + column = ( + + ); + break; + + case "transfer_to_blind": + column = ( + + ); + break; + + case "transfer_from_blind": + column = ( + + ); + break; + + case "asset_claim_fees": + column = ( + + ); + break; + + case "committee_member_update_global_parameters": + column = ; + break; + + case "custom": + column = ; + break; + + case "override_transfer": + column = ; + break; + + default: + return ; + } +} From 668dffd9aafd4de4a1807a4f8078a89f59e8cb1d Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Tue, 26 Mar 2019 19:28:40 +0200 Subject: [PATCH 05/12] started refactoring of operations to single resolver --- app/components/Blockchain/Operation.jsx | 2217 +++++++---------- .../Blockchain/ProposedOperation.jsx | 1 + .../Blockchain/operations/AccountCreate.jsx | 62 +- .../Blockchain/operations/AccountTransfer.jsx | 48 +- .../Blockchain/operations/AccountUpdate.jsx | 8 +- .../Blockchain/operations/AccountUpgrade.jsx | 52 +- .../operations/AccountWhitelist.jsx | 60 +- .../Blockchain/operations/AssetCreate.jsx | 55 +- .../Blockchain/operations/AssetUpdate.jsx | 8 +- .../Blockchain/operations/CallOrderUpdate.jsx | 2 +- .../Blockchain/operations/KeyCreate.jsx | 2 +- .../operations/LimitOrderCancel.jsx | 44 +- .../operations/LimitOrderCreate.jsx | 152 +- .../Blockchain/operations/ProposalCreate.jsx | 71 +- .../Blockchain/operations/Transfer.jsx | 4 +- app/components/Blockchain/operations/index.js | 138 +- 16 files changed, 1413 insertions(+), 1511 deletions(-) diff --git a/app/components/Blockchain/Operation.jsx b/app/components/Blockchain/Operation.jsx index b509600407..ca2ca98ea9 100644 --- a/app/components/Blockchain/Operation.jsx +++ b/app/components/Blockchain/Operation.jsx @@ -201,6 +201,17 @@ class Operation extends React.Component { } } + shouldComponentUpdate(nextProps, nextState) { + if (!this.props.op || !nextProps.op) { + return false; + } + return ( + !utils.are_equal_shallow(nextProps.op[1], this.props.op[1]) || + nextProps.marketDirections !== this.props.marketDirections || + this.state.labelColor !== nextState.labelColor + ); + } + linkToAccount(name_or_id) { if (!name_or_id) return -; return utils.is_object_id(name_or_id) ? ( @@ -219,17 +230,6 @@ class Operation extends React.Component { ); } - shouldComponentUpdate(nextProps, nextState) { - if (!this.props.op || !nextProps.op) { - return false; - } - return ( - !utils.are_equal_shallow(nextProps.op[1], this.props.op[1]) || - nextProps.marketDirections !== this.props.marketDirections || - this.state.labelColor !== nextState.labelColor - ); - } - changeColor = newColor => { const {labelColor} = this.state; if (labelColor !== newColor) { @@ -238,1317 +238,896 @@ class Operation extends React.Component { }; render() { - let {op, current, block} = this.props; + let {op, block} = this.props; let line = null, - column = null, - color = "info"; - let memoComponent = null; + column = null; console.log("Operation component", ops[op[0]]); - switch ( - ops[op[0]] // For a list of trx types, see chain_types.coffee - ) { - case "transfer": - /* if (op[1].memo) { - memoComponent = ; - } - - color = "success"; - op[1].amount.amount = parseFloat(op[1].amount.amount); - - column = ( - - - {memoComponent} - - ); */ - column = opComponents("transfer", this.props, { - changeColor: this.changeColor - }); - - break; - - case "limit_order_create": - color = "warning"; - let o = op[1]; - /* - marketName = OPEN.ETH_USD - if (!inverted) (default) - price = USD / OPEN.ETH - buy / sell OPEN.ETH - isBid = amount_to_sell.asset_symbol = USD - amount = to_receive - if (inverted) - price = OPEN.ETH / USD - buy / sell USD - isBid = amount_to_sell.asset_symbol = OPEN.ETH - amount = - */ - column = ( - - - {({base, quote}) => { - const { - marketName, - first, - second - } = marketUtils.getMarketName(base, quote); - const inverted = this.props.marketDirections.get( - marketName - ); - // const paySymbol = base.get("symbol"); - // const receiveSymbol = quote.get("symbol"); - - const isBid = - o.amount_to_sell.asset_id === - (inverted - ? first.get("id") - : second.get("id")); - - let priceBase = isBid - ? o.amount_to_sell - : o.min_to_receive; - let priceQuote = isBid - ? o.min_to_receive - : o.amount_to_sell; - const amount = isBid - ? op[1].min_to_receive - : op[1].amount_to_sell; - let orderId = this.props.result - ? typeof this.props.result[1] == "string" - ? "#" + - this.props.result[1].substring(4) - : "" - : ""; - - return ( - - ); - }} - - - ); - break; - - case "limit_order_cancel": - color = "cancel"; - column = ( - - - - ); - break; - - case "call_order_update": - color = "warning"; - - column = ( - - - - ); - break; - - case "key_create": - column = ( - - - - ); - break; - - case "account_create": - column = ( - - ); - break; - - case "account_update": - column = ( - - - - ); - - break; - - case "account_whitelist": - let label = - op[1].new_listing === listings.no_listing - ? "unlisted_by" - : op[1].new_listing === listings.white_listed - ? "whitelisted_by" - : "blacklisted_by"; - column = ( - - - - ); - break; - - case "account_upgrade": - column = ( - - - - ); - break; - - case "account_transfer": - column = ( - - - - ); - break; - - case "asset_create": - color = "warning"; - column = ( - - - - ); - break; - - case "asset_update": - case "asset_update_bitasset": - color = "warning"; - column = ( - - - - ); - break; - - case "asset_update_feed_producers": - color = "warning"; - - column = ( - - - - ); - break; - - case "asset_issue": - color = "warning"; - - if (op[1].memo) { - memoComponent = ; - } - - op[1].asset_to_issue.amount = parseInt( - op[1].asset_to_issue.amount, - 10 - ); - column = ( - - - {memoComponent} - - ); - break; - - case "asset_fund_fee_pool": - color = "warning"; - - column = ( - - - - ); - break; - - case "asset_settle": - color = "warning"; - const baseAmount = op[1].amount; - const instantSettleCode = 2; - if ( - this.props.result && - this.props.result[0] == instantSettleCode - ) { - const quoteAmount = this.props.result[1]; - column = ( - - - - ); - } else { - column = ( - - - - ); - } - - break; - - case "asset_global_settle": - color = "warning"; - column = ( - - - - ); - break; - - case "asset_publish_feed": - color = "warning"; - column = ( - - - - ); - break; - - case "witness_create": - column = ( - - - - ); - - break; - - case "witness_update": - column = ( - - - - ); - - break; - - case "witness_withdraw_pay": - console.log("witness_withdraw_pay:", op[1].witness_account); - if (current === op[1].witness_account) { - column = ( - - -   - - -   - {this.linkToAccount(op[1].witness_account)} - - ); - } else { - column = ( - - -   - - -   - {this.linkToAccount(op[1].witness_account)} - - ); - } - break; - - case "proposal_create": - column = ( -
- - - ) : ( - "" - ), - arg: "proposal" - } - ]} - /> - : - -
- {op[1].proposed_ops.map((o, index) => { - return ( - - ); - })} -
-
- ); - break; - - case "proposal_update": - const fields = [ - "active_approvals_to_add", - "active_approvals_to_remove", - "owner_approvals_to_add", - "owner_approvals_to_remove", - "key_approvals_to_add", - "key_approvals_to_remove" - ]; - column = ( -
- - - ), - arg: "proposal" - } - ]} - /> - -
- {fields.map(field => { - if (op[1][field].length) { - return ( -
- -
    - {op[1][field].map(value => { - return ( -
  • - {field.startsWith( - "key" - ) - ? value - : this.linkToAccount( - value - )} -
  • - ); - })} -
-
- ); - } else return null; - })} -
-
- ); - break; - - case "proposal_delete": - column = ( - - - ), - arg: "proposal" - } - ]} - /> - - ); - break; - - case "withdraw_permission_create": - column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].authorized_account)} - - ); - break; - - case "withdraw_permission_update": - column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].authorized_account)} - - ); - break; - - case "withdraw_permission_claim": - column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].withdraw_to_account)} - - ); - break; - - case "withdraw_permission_delete": - column = ( - - -   - {this.linkToAccount(op[1].withdraw_from_account)} - -   - {this.linkToAccount(op[1].authorized_account)} - - ); - break; - - case "fill_order": - color = "success"; - o = op[1]; - - /* - marketName = OPEN.ETH_USD - if (!inverted) (default) - price = USD / OPEN.ETH - buy / sell OPEN.ETH - isBid = amount_to_sell.asset_symbol = USD - amount = to_receive - if (inverted) - price = OPEN.ETH / USD - buy / sell USD - isBid = amount_to_sell.asset_symbol = OPEN.ETH - amount = - - const {marketName, first, second} = marketUtils.getMarketName(base, quote); - const inverted = this.props.marketDirections.get(marketName); - // const paySymbol = base.get("symbol"); - // const receiveSymbol = quote.get("symbol"); - - const isBid = o.amount_to_sell.asset_id === (inverted ? first.get("id") : second.get("id")); - - let priceBase = (isBid) ? o.amount_to_sell : o.min_to_receive; - let priceQuote = (isBid) ? o.min_to_receive : o.amount_to_sell; - const amount = isBid ? op[1].min_to_receive : op[1].amount_to_sell; - */ - - column = ( - - - {({base, quote}) => { - const { - marketName, - first, - second - } = marketUtils.getMarketName(base, quote); - const inverted = this.props.marketDirections.get( - marketName - ); - const isBid = - o.pays.asset_id === - (inverted - ? first.get("id") - : second.get("id")); - - // const paySymbol = base.get("symbol"); - // const receiveSymbol = quote.get("symbol"); - let priceBase = isBid ? o.receives : o.pays; - let priceQuote = isBid ? o.pays : o.receives; - let amount = isBid ? o.receives : o.pays; - let receivedAmount = - o.fee.asset_id === amount.asset_id - ? amount.amount - o.fee.amount - : amount.amount; - - return ( - - ); - }} - - - ); - break; - - case "global_parameters_update": - column = ( - - - - ); - break; - - case "vesting_balance_create": - column = ( - -   - {this.linkToAccount(op[1].creator)} - -   - -   - {this.linkToAccount(op[1].owner)} - - ); - break; - - case "vesting_balance_withdraw": - column = ( - - - - ); - break; - - case "worker_create": - column = ( - - - - ); - break; - - case "balance_claim": - color = "success"; - op[1].total_claimed.amount = parseInt( - op[1].total_claimed.amount, - 10 - ); - column = ( - - - - ); - break; - - case "committee_member_create": - column = ( - - -   - {this.linkToAccount(op[1].committee_member_account)} - - ); - break; - - case "transfer_to_blind": - column = ( - - {this.linkToAccount(op[1].from)} -   - -   - - - ); - break; - - case "transfer_from_blind": - column = ( - - {this.linkToAccount(op[1].to)} -   - -   - - - ); - break; - - case "asset_claim_fees": - color = "success"; - op[1].amount_to_claim.amount = parseInt( - op[1].amount_to_claim.amount, - 10 - ); - column = ( - - {this.linkToAccount(op[1].issuer)} -   - - {({asset}) => ( - - )} - - - ); - break; - - case "custom": - column = ( - - - - ); - break; - - case "asset_reserve": - column = ( - - - - ); - break; - - case "committee_member_update_global_parameters": - console.log( - "committee_member_update_global_parameters op:", - op - ); - column = ( - - - - ); - break; - - case "override_transfer": - column = ( - - ); - break; - - case "asset_settle_cancel": - column = ( - - ); - break; - - case "asset_claim_pool": - column = ( - - ); - break; - - case "asset_update_issuer": - column = ( - - ); - break; - - case "bid_collateral": - column = ( - - ); - break; - - default: - console.log("unimplemented op '" + ops[op[0]] + "':", op); - column = ( - - #{block} - - ); - } + + column = opComponents(ops[op[0]], this.props, { + fromComponent: "operation", + linkToAccount: this.linkToAccount, + linkToAsset: this.linkToAsset, + changeColor: this.changeColor + }); + + // switch ( + // ops[op[0]] + // ) { + + // case "asset_update_feed_producers": + // color = "warning"; + + // column = ( + // + // + // + // ); + // break; + + // case "asset_issue": + // color = "warning"; + + // if (op[1].memo) { + // memoComponent = ; + // } + + // op[1].asset_to_issue.amount = parseInt( + // op[1].asset_to_issue.amount, + // 10 + // ); + // column = ( + // + // + // {memoComponent} + // + // ); + // break; + + // case "asset_fund_fee_pool": + // color = "warning"; + + // column = ( + // + // + // + // ); + // break; + + // case "asset_settle": + // color = "warning"; + // const baseAmount = op[1].amount; + // const instantSettleCode = 2; + // if ( + // this.props.result && + // this.props.result[0] == instantSettleCode + // ) { + // const quoteAmount = this.props.result[1]; + // column = ( + // + // + // + // ); + // } else { + // column = ( + // + // + // + // ); + // } + + // break; + + // case "asset_global_settle": + // color = "warning"; + // column = ( + // + // + // + // ); + // break; + + // case "asset_publish_feed": + // color = "warning"; + // column = ( + // + // + // + // ); + // break; + + // case "witness_create": + // column = ( + // + // + // + // ); + + // break; + + // case "witness_update": + // column = ( + // + // + // + // ); + + // break; + + // case "witness_withdraw_pay": + // console.log("witness_withdraw_pay:", op[1].witness_account); + // if (current === op[1].witness_account) { + // column = ( + // + // + //   + // + // + //   + // {this.linkToAccount(op[1].witness_account)} + // + // ); + // } else { + // column = ( + // + // + //   + // + // + //   + // {this.linkToAccount(op[1].witness_account)} + // + // ); + // } + // break; + + // case "proposal_update": + // const fields = [ + // "active_approvals_to_add", + // "active_approvals_to_remove", + // "owner_approvals_to_add", + // "owner_approvals_to_remove", + // "key_approvals_to_add", + // "key_approvals_to_remove" + // ]; + // column = ( + //
+ // + // + // ), + // arg: "proposal" + // } + // ]} + // /> + // + //
+ // {fields.map(field => { + // if (op[1][field].length) { + // return ( + //
+ // + //
    + // {op[1][field].map(value => { + // return ( + //
  • + // {field.startsWith( + // "key" + // ) + // ? value + // : this.linkToAccount( + // value + // )} + //
  • + // ); + // })} + //
+ //
+ // ); + // } else return null; + // })} + //
+ //
+ // ); + // break; + + // case "proposal_delete": + // column = ( + // + // + // ), + // arg: "proposal" + // } + // ]} + // /> + // + // ); + // break; + + // case "withdraw_permission_create": + // column = ( + // + // + //   + // {this.linkToAccount(op[1].withdraw_from_account)} + // + //   + // {this.linkToAccount(op[1].authorized_account)} + // + // ); + // break; + + // case "withdraw_permission_update": + // column = ( + // + // + //   + // {this.linkToAccount(op[1].withdraw_from_account)} + // + //   + // {this.linkToAccount(op[1].authorized_account)} + // + // ); + // break; + + // case "withdraw_permission_claim": + // column = ( + // + // + //   + // {this.linkToAccount(op[1].withdraw_from_account)} + // + //   + // {this.linkToAccount(op[1].withdraw_to_account)} + // + // ); + // break; + + // case "withdraw_permission_delete": + // column = ( + // + // + //   + // {this.linkToAccount(op[1].withdraw_from_account)} + // + //   + // {this.linkToAccount(op[1].authorized_account)} + // + // ); + // break; + + // case "fill_order": + // color = "success"; + // o = op[1]; + + // column = ( + // + // + // {({base, quote}) => { + // const { + // marketName, + // first, + // second + // } = marketUtils.getMarketName(base, quote); + // const inverted = this.props.marketDirections.get( + // marketName + // ); + // const isBid = + // o.pays.asset_id === + // (inverted + // ? first.get("id") + // : second.get("id")); + + // let priceBase = isBid ? o.receives : o.pays; + // let priceQuote = isBid ? o.pays : o.receives; + // let amount = isBid ? o.receives : o.pays; + // let receivedAmount = + // o.fee.asset_id === amount.asset_id + // ? amount.amount - o.fee.amount + // : amount.amount; + + // return ( + // + // ); + // }} + // + // + // ); + // break; + + // case "global_parameters_update": + // column = ( + // + // + // + // ); + // break; + + // case "vesting_balance_create": + // column = ( + // + //   + // {this.linkToAccount(op[1].creator)} + // + //   + // + //   + // {this.linkToAccount(op[1].owner)} + // + // ); + // break; + + // case "vesting_balance_withdraw": + // column = ( + // + // + // + // ); + // break; + + // case "worker_create": + // column = ( + // + // + // + // ); + // break; + + // case "balance_claim": + // color = "success"; + // op[1].total_claimed.amount = parseInt( + // op[1].total_claimed.amount, + // 10 + // ); + // column = ( + // + // + // + // ); + // break; + + // case "committee_member_create": + // column = ( + // + // + //   + // {this.linkToAccount(op[1].committee_member_account)} + // + // ); + // break; + + // case "transfer_to_blind": + // column = ( + // + // {this.linkToAccount(op[1].from)} + //   + // + //   + // + // + // ); + // break; + + // case "transfer_from_blind": + // column = ( + // + // {this.linkToAccount(op[1].to)} + //   + // + //   + // + // + // ); + // break; + + // case "asset_claim_fees": + // color = "success"; + // op[1].amount_to_claim.amount = parseInt( + // op[1].amount_to_claim.amount, + // 10 + // ); + // column = ( + // + // {this.linkToAccount(op[1].issuer)} + //   + // + // {({asset}) => ( + // + // )} + // + // + // ); + // break; + + // case "custom": + // column = ( + // + // + // + // ); + // break; + + // case "asset_reserve": + // column = ( + // + // + // + // ); + // break; + + // case "committee_member_update_global_parameters": + // console.log( + // "committee_member_update_global_parameters op:", + // op + // ); + // column = ( + // + // + // + // ); + // break; + + // case "override_transfer": + // column = ( + // + // ); + // break; + + // case "asset_settle_cancel": + // column = ( + // + // ); + // break; + + // case "asset_claim_pool": + // column = ( + // + // ); + // break; + + // case "asset_update_issuer": + // column = ( + // + // ); + // break; + + // case "bid_collateral": + // column = ( + // + // ); + // break; + + // default: + // console.log("unimplemented op '" + ops[op[0]] + "':", op); + // column = ( + // + // #{block} + // + // ); + // } if (this.props.csvExportMode) { const globalObject = ChainStore.getObject("2.0.0"); diff --git a/app/components/Blockchain/ProposedOperation.jsx b/app/components/Blockchain/ProposedOperation.jsx index 5423a7a077..e70fe58ac4 100644 --- a/app/components/Blockchain/ProposedOperation.jsx +++ b/app/components/Blockchain/ProposedOperation.jsx @@ -138,6 +138,7 @@ class ProposedOperation extends React.Component { let line = null, column = null; column = opComponents(ops[op[0]], this.props, { + fromComponent: "proposed_operation", linkToAccount: this.linkToAccount, linkToAsset: this.linkToAsset, changeColor: this.changeColor diff --git a/app/components/Blockchain/operations/AccountCreate.jsx b/app/components/Blockchain/operations/AccountCreate.jsx index 7e2879d67e..a9bdf60b20 100644 --- a/app/components/Blockchain/operations/AccountCreate.jsx +++ b/app/components/Blockchain/operations/AccountCreate.jsx @@ -1,27 +1,51 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AccountCreate = ({op, current, linkToAccount}) => { - if (current === op[1].registrar) { - return ( - - -   - {linkToAccount(op[1].name)} - - ); +export const AccountCreate = ({op, current, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + if (current === op[1].registrar) { + return ( + + +   + {linkToAccount(op[1].name)} + + ); + } else { + return ( + + {linkToAccount(op[1].name)} +   + +   + {linkToAccount(op[1].registrar)} + + ); + } } else { return ( - - {linkToAccount(op[1].name)} -   - -   - {linkToAccount(op[1].registrar)} - + ); } }; diff --git a/app/components/Blockchain/operations/AccountTransfer.jsx b/app/components/Blockchain/operations/AccountTransfer.jsx index a50528c73e..5687eaa66e 100644 --- a/app/components/Blockchain/operations/AccountTransfer.jsx +++ b/app/components/Blockchain/operations/AccountTransfer.jsx @@ -1,15 +1,41 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AccountTransfer = ({op, linkToAccount}) => { - return ( - - -   - {linkToAccount(op[1].account_id)} - -   - {linkToAccount(op[1].new_owner)} - - ); +export const AccountTransfer = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].account_id)} + +   + {linkToAccount(op[1].new_owner)} + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx index 27e11cc7c6..f614243f4c 100644 --- a/app/components/Blockchain/operations/AccountUpdate.jsx +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -1,11 +1,15 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AccountUpdate = ({op}) => { +export const AccountUpdate = ({op, fromComponent}) => { return ( { - if (op[1].upgrade_to_lifetime_member) { - return ( - - {linkToAccount(op[1].account_to_upgrade)}   - - - ); +export const AccountUpgrade = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + if (op[1].upgrade_to_lifetime_member) { + return ( + + {linkToAccount(op[1].account_to_upgrade)}   + + + ); + } else { + return ( + + {linkToAccount(op[1].account_to_upgrade)}   + + + ); + } } else { return ( - {linkToAccount(op[1].account_to_upgrade)}   - ); diff --git a/app/components/Blockchain/operations/AccountWhitelist.jsx b/app/components/Blockchain/operations/AccountWhitelist.jsx index 01e535faec..056b5f59c4 100644 --- a/app/components/Blockchain/operations/AccountWhitelist.jsx +++ b/app/components/Blockchain/operations/AccountWhitelist.jsx @@ -1,30 +1,52 @@ import React from "react"; import Translate from "react-translate-component"; import BindToChainState from "../../Utility/BindToChainState"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AccountWhitelist = ({op}) => { +export const AccountWhitelist = ({op, fromComponent}) => { let label = op[1].new_listing === listings.no_listing ? "unlisted_by" : op[1].new_listing === listings.white_listed ? "whitelisted_by" : "blacklisted_by"; - - return ( - - - {({lister, listee}) => ( - - )} - - - ); + if (fromComponent === "proposed_operation") { + return ( + + + {({lister, listee}) => ( + + )} + + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AssetCreate.jsx b/app/components/Blockchain/operations/AssetCreate.jsx index 562d6d139d..5076a9f1d1 100644 --- a/app/components/Blockchain/operations/AssetCreate.jsx +++ b/app/components/Blockchain/operations/AssetCreate.jsx @@ -1,22 +1,43 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AssetCreate = ({op, changeColor}) => { +export const AssetCreate = ({op, changeColor, fromComponent}) => { changeColor("warning"); - - return ( - - ); + if (fromComponent === "proposed_operation") { + return ( + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AssetUpdate.jsx b/app/components/Blockchain/operations/AssetUpdate.jsx index 534f42e06d..37516aac4c 100644 --- a/app/components/Blockchain/operations/AssetUpdate.jsx +++ b/app/components/Blockchain/operations/AssetUpdate.jsx @@ -1,12 +1,16 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AssetUpdate = ({op, changeColor}) => { +export const AssetUpdate = ({op, changeColor, fromComponent}) => { changeColor("warning"); return ( { return ( { return ( - + ); }; diff --git a/app/components/Blockchain/operations/LimitOrderCancel.jsx b/app/components/Blockchain/operations/LimitOrderCancel.jsx index 695d58ed6b..50111c8adb 100644 --- a/app/components/Blockchain/operations/LimitOrderCancel.jsx +++ b/app/components/Blockchain/operations/LimitOrderCancel.jsx @@ -1,16 +1,40 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const LimitOrderCancel = ({op, changeColor}) => { +export const LimitOrderCancel = ({op, changeColor, fromComponent}) => { changeColor("cancel"); - return ( - - {this.linkToAccount(op[1].fee_paying_account)} -   - -  # - {op[1].order.substring(4)} - - ); + if (fromComponent === "proposed_operation") { + return ( + + {this.linkToAccount(op[1].fee_paying_account)} +   + +  # + {op[1].order.substring(4)} + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/LimitOrderCreate.jsx b/app/components/Blockchain/operations/LimitOrderCreate.jsx index 1c0d643228..f45f70d129 100644 --- a/app/components/Blockchain/operations/LimitOrderCreate.jsx +++ b/app/components/Blockchain/operations/LimitOrderCreate.jsx @@ -1,45 +1,123 @@ +/* eslint-disable react/display-name */ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; +import BindToChainState from "../../Utility/BindToChainState"; -export const LimitOrderCreate = ({op, changeColor}) => { +export const LimitOrderCreate = ({op, changeColor, fromComponent}) => { changeColor("warning"); - let isAsk = market_utils.isAskOp(op[1]); - return ( - - + - - ); + { + type: "price", + value: { + base: isAsk + ? op[1].min_to_receive + : op[1].amount_to_sell, + quote: isAsk + ? op[1].amount_to_sell + : op[1].min_to_receive + }, + arg: "price" + } + ]} + /> + + ); + } else { + let o = op[1]; + return ( + + + {({base, quote}) => { + const { + marketName, + first, + second + } = marketUtils.getMarketName(base, quote); + const inverted = this.props.marketDirections.get( + marketName + ); + + const isBid = + o.amount_to_sell.asset_id === + (inverted ? first.get("id") : second.get("id")); + + let priceBase = isBid + ? o.amount_to_sell + : o.min_to_receive; + let priceQuote = isBid + ? o.min_to_receive + : o.amount_to_sell; + const amount = isBid + ? op[1].min_to_receive + : op[1].amount_to_sell; + let orderId = this.props.result + ? typeof this.props.result[1] == "string" + ? "#" + this.props.result[1].substring(4) + : "" + : ""; + + return ( + + ); + }} + + + ); + } }; diff --git a/app/components/Blockchain/operations/ProposalCreate.jsx b/app/components/Blockchain/operations/ProposalCreate.jsx index 63926e2786..8089152bb3 100644 --- a/app/components/Blockchain/operations/ProposalCreate.jsx +++ b/app/components/Blockchain/operations/ProposalCreate.jsx @@ -1,10 +1,69 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; +import ProposedOperation from "../ProposedOperation"; -export const ProposalCreate = () => { - return ( - - - - ); +const ShortObjectId = ({objectId}) => { + if (typeof objectId === "string") { + const parts = objectId.split("."); + const {length} = parts; + if (length > 0) return "#" + parts[length - 1]; + } + return objectId; +}; + +export const ProposalCreate = ({op, result, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + + + ); + } else { + return ( +
+ + + ) : ( + "" + ), + arg: "proposal" + } + ]} + /> + : + +
+ {op[1] && + op[1].proposed_ops.map((o, index) => { + return ( + + ); + })} +
+
+ ); + } }; diff --git a/app/components/Blockchain/operations/Transfer.jsx b/app/components/Blockchain/operations/Transfer.jsx index 91f67fe3e5..aa7f9d5e85 100644 --- a/app/components/Blockchain/operations/Transfer.jsx +++ b/app/components/Blockchain/operations/Transfer.jsx @@ -3,7 +3,7 @@ import TranslateWithLinks from "../../Utility/TranslateWithLinks"; import MemoText from "../MemoText"; export const Transfer = ({op, proposer, index, changeColor}) => { - changeColor("success"); // color of label + changeColor("success"); // color of a label let memoComponent = null; if (op[1].memo) { @@ -31,7 +31,7 @@ export const Transfer = ({op, proposer, index, changeColor}) => { ) : null}
+ ); break; case "limit_order_cancel": - column = ( - + return ( + ); break; case "short_order_cancel": - column = ( + return ( ); break; case "call_order_update": - column = ( + return ( ); break; case "key_create": - column = ; + return ; break; case "account_create": - column = ( - + return ( + ); break; case "account_update": - column = ; + return ( + + ); break; case "account_whitelist": - column = ; + return ( + + ); break; case "account_upgrade": - column = ( - + return ( + ); break; case "account_transfer": - column = ( + return ( ); break; case "asset_create": - column = ; + return ( + + ); break; case "asset_update": case "asset_update_bitasset": - column = ; + return ( + + ); break; case "asset_update_feed_producers": - column = ( + return ( ; + return ; break; case "asset_reserve": - column = ; + return ; break; case "asset_fund_fee_pool": - column = ( + return ( ; + return ; break; case "asset_global_settle": - column = ( + return ( ); break; case "witness_update": - column = ; + return ; break; case "witness_withdraw_pay": - column = ( + return ( ; + return ( + + ); break; case "proposal_update": - column = ; + return ; break; case "proposal_delete": - column = ; + return ; break; case "withdraw_permission_create": - column = ( + return ( ; + return ; break; case "fill_order": - column = ( + return ( ; + return ; break; case "file_write": - column = ; + return ; break; case "vesting_balance_create": - column = ( + return ( ; + return ; break; case "bond_create_offer": - column = ; + return ; break; case "bond_cancel_offer": - column = ; + return ; break; case "bond_accept_offer": - column = ( + return ( ; + return ; break; case "balance_claim": - column = ( + return ( ; + return ; break; case "custom": - column = ; + return ; break; case "override_transfer": - column = ; + return ; break; default: From 04b698d1828b55423f673bb8163ba6b800c248c9 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Fri, 29 Mar 2019 12:36:21 +0200 Subject: [PATCH 06/12] finish refactoring of operations --- app/components/Blockchain/Operation.jsx | 895 +----------------- .../Blockchain/operations/AssetClaimPool.jsx | 27 + .../operations/AssetFundFeePool.jsx | 77 +- .../operations/AssetGlobalSettle.jsx | 76 +- .../Blockchain/operations/AssetIssue.jsx | 10 +- .../operations/AssetPublishFeed.jsx | 59 +- .../Blockchain/operations/AssetReserve.jsx | 8 +- .../Blockchain/operations/AssetSettle.jsx | 96 +- .../operations/AssetSettleCancel.jsx | 18 + .../operations/AssetUpdateFeedProducers.jsx | 58 +- .../operations/AssetUpdateIssuer.jsx | 27 + .../Blockchain/operations/BalanceClaim.jsx | 68 +- .../Blockchain/operations/BidCollateral.jsx | 27 + .../Blockchain/operations/BondAcceptOffer.jsx | 2 +- .../operations/BondClaimCollaterial.jsx | 2 +- .../Blockchain/operations/CallOrderUpdate.jsx | 8 +- .../CommitteeMemberUpdateGlobalParams.jsx | 8 +- .../operations/CommittyMemberCreate.jsx | 8 +- .../Blockchain/operations/Custom.jsx | 11 +- .../Blockchain/operations/FillOrder.jsx | 137 ++- .../operations/GlobalParametersUpdate.jsx | 8 +- .../operations/LimitOrderCancel.jsx | 9 +- .../operations/LimitOrderCreate.jsx | 20 +- .../operations/OverrideTransfer.jsx | 8 +- .../Blockchain/operations/ProposalDelete.jsx | 46 +- .../Blockchain/operations/ProposalUpdate.jsx | 82 +- .../operations/TransferFromBlind.jsx | 11 +- .../Blockchain/operations/TransferToBlind.jsx | 11 +- .../operations/VestingBalanceCreate.jsx | 58 +- .../operations/VestingBalanceWithdraw.jsx | 8 +- .../operations/WithdrawPermissionClaim.jsx | 44 +- .../operations/WithdrawPermissionCreate.jsx | 48 +- .../operations/WithdrawPermissionDelete.jsx | 48 +- .../operations/WithdrawPermissionUpdate.jsx | 48 +- .../Blockchain/operations/WitnessCreate.jsx | 34 +- .../Blockchain/operations/WitnessUpdate.jsx | 34 +- .../operations/WitnessWithdrawPay.jsx | 100 +- .../Blockchain/operations/WorkerCreate.jsx | 53 +- app/components/Blockchain/operations/index.js | 267 ++---- 39 files changed, 1140 insertions(+), 1419 deletions(-) create mode 100644 app/components/Blockchain/operations/AssetClaimPool.jsx create mode 100644 app/components/Blockchain/operations/AssetSettleCancel.jsx create mode 100644 app/components/Blockchain/operations/AssetUpdateIssuer.jsx create mode 100644 app/components/Blockchain/operations/BidCollateral.jsx diff --git a/app/components/Blockchain/Operation.jsx b/app/components/Blockchain/Operation.jsx index ca2ca98ea9..68adf3bbad 100644 --- a/app/components/Blockchain/Operation.jsx +++ b/app/components/Blockchain/Operation.jsx @@ -10,12 +10,8 @@ import LinkToAccountById from "../Utility/LinkToAccountById"; import LinkToAssetById from "../Utility/LinkToAssetById"; import BindToChainState from "../Utility/BindToChainState"; import ChainTypes from "../Utility/ChainTypes"; -import TranslateWithLinks from "../Utility/TranslateWithLinks"; import {ChainStore, ChainTypes as grapheneChainTypes} from "bitsharesjs"; import account_constants from "chain/account_constants"; -import MemoText from "./MemoText"; -import ProposedOperation from "./ProposedOperation"; -import marketUtils from "common/market_utils"; import {connect} from "alt-react"; import SettingsStore from "stores/SettingsStore"; import PropTypes from "prop-types"; @@ -26,16 +22,7 @@ import opComponents from "./operations"; require("./operations.scss"); let ops = Object.keys(operations); -let listings = account_constants.account_listing; - -const ShortObjectId = ({objectId}) => { - if (typeof objectId === "string") { - const parts = objectId.split("."); - const {length} = parts; - if (length > 0) return "#" + parts[length - 1]; - } - return objectId; -}; +// let listings = account_constants.account_listing; class TransactionLabel extends React.Component { shouldComponentUpdate(nextProps) { @@ -242,8 +229,6 @@ class Operation extends React.Component { let line = null, column = null; - console.log("Operation component", ops[op[0]]); - column = opComponents(ops[op[0]], this.props, { fromComponent: "operation", linkToAccount: this.linkToAccount, @@ -251,884 +236,6 @@ class Operation extends React.Component { changeColor: this.changeColor }); - // switch ( - // ops[op[0]] - // ) { - - // case "asset_update_feed_producers": - // color = "warning"; - - // column = ( - // - // - // - // ); - // break; - - // case "asset_issue": - // color = "warning"; - - // if (op[1].memo) { - // memoComponent = ; - // } - - // op[1].asset_to_issue.amount = parseInt( - // op[1].asset_to_issue.amount, - // 10 - // ); - // column = ( - // - // - // {memoComponent} - // - // ); - // break; - - // case "asset_fund_fee_pool": - // color = "warning"; - - // column = ( - // - // - // - // ); - // break; - - // case "asset_settle": - // color = "warning"; - // const baseAmount = op[1].amount; - // const instantSettleCode = 2; - // if ( - // this.props.result && - // this.props.result[0] == instantSettleCode - // ) { - // const quoteAmount = this.props.result[1]; - // column = ( - // - // - // - // ); - // } else { - // column = ( - // - // - // - // ); - // } - - // break; - - // case "asset_global_settle": - // color = "warning"; - // column = ( - // - // - // - // ); - // break; - - // case "asset_publish_feed": - // color = "warning"; - // column = ( - // - // - // - // ); - // break; - - // case "witness_create": - // column = ( - // - // - // - // ); - - // break; - - // case "witness_update": - // column = ( - // - // - // - // ); - - // break; - - // case "witness_withdraw_pay": - // console.log("witness_withdraw_pay:", op[1].witness_account); - // if (current === op[1].witness_account) { - // column = ( - // - // - //   - // - // - //   - // {this.linkToAccount(op[1].witness_account)} - // - // ); - // } else { - // column = ( - // - // - //   - // - // - //   - // {this.linkToAccount(op[1].witness_account)} - // - // ); - // } - // break; - - // case "proposal_update": - // const fields = [ - // "active_approvals_to_add", - // "active_approvals_to_remove", - // "owner_approvals_to_add", - // "owner_approvals_to_remove", - // "key_approvals_to_add", - // "key_approvals_to_remove" - // ]; - // column = ( - //
- // - // - // ), - // arg: "proposal" - // } - // ]} - // /> - // - //
- // {fields.map(field => { - // if (op[1][field].length) { - // return ( - //
- // - //
    - // {op[1][field].map(value => { - // return ( - //
  • - // {field.startsWith( - // "key" - // ) - // ? value - // : this.linkToAccount( - // value - // )} - //
  • - // ); - // })} - //
- //
- // ); - // } else return null; - // })} - //
- //
- // ); - // break; - - // case "proposal_delete": - // column = ( - // - // - // ), - // arg: "proposal" - // } - // ]} - // /> - // - // ); - // break; - - // case "withdraw_permission_create": - // column = ( - // - // - //   - // {this.linkToAccount(op[1].withdraw_from_account)} - // - //   - // {this.linkToAccount(op[1].authorized_account)} - // - // ); - // break; - - // case "withdraw_permission_update": - // column = ( - // - // - //   - // {this.linkToAccount(op[1].withdraw_from_account)} - // - //   - // {this.linkToAccount(op[1].authorized_account)} - // - // ); - // break; - - // case "withdraw_permission_claim": - // column = ( - // - // - //   - // {this.linkToAccount(op[1].withdraw_from_account)} - // - //   - // {this.linkToAccount(op[1].withdraw_to_account)} - // - // ); - // break; - - // case "withdraw_permission_delete": - // column = ( - // - // - //   - // {this.linkToAccount(op[1].withdraw_from_account)} - // - //   - // {this.linkToAccount(op[1].authorized_account)} - // - // ); - // break; - - // case "fill_order": - // color = "success"; - // o = op[1]; - - // column = ( - // - // - // {({base, quote}) => { - // const { - // marketName, - // first, - // second - // } = marketUtils.getMarketName(base, quote); - // const inverted = this.props.marketDirections.get( - // marketName - // ); - // const isBid = - // o.pays.asset_id === - // (inverted - // ? first.get("id") - // : second.get("id")); - - // let priceBase = isBid ? o.receives : o.pays; - // let priceQuote = isBid ? o.pays : o.receives; - // let amount = isBid ? o.receives : o.pays; - // let receivedAmount = - // o.fee.asset_id === amount.asset_id - // ? amount.amount - o.fee.amount - // : amount.amount; - - // return ( - // - // ); - // }} - // - // - // ); - // break; - - // case "global_parameters_update": - // column = ( - // - // - // - // ); - // break; - - // case "vesting_balance_create": - // column = ( - // - //   - // {this.linkToAccount(op[1].creator)} - // - //   - // - //   - // {this.linkToAccount(op[1].owner)} - // - // ); - // break; - - // case "vesting_balance_withdraw": - // column = ( - // - // - // - // ); - // break; - - // case "worker_create": - // column = ( - // - // - // - // ); - // break; - - // case "balance_claim": - // color = "success"; - // op[1].total_claimed.amount = parseInt( - // op[1].total_claimed.amount, - // 10 - // ); - // column = ( - // - // - // - // ); - // break; - - // case "committee_member_create": - // column = ( - // - // - //   - // {this.linkToAccount(op[1].committee_member_account)} - // - // ); - // break; - - // case "transfer_to_blind": - // column = ( - // - // {this.linkToAccount(op[1].from)} - //   - // - //   - // - // - // ); - // break; - - // case "transfer_from_blind": - // column = ( - // - // {this.linkToAccount(op[1].to)} - //   - // - //   - // - // - // ); - // break; - - // case "asset_claim_fees": - // color = "success"; - // op[1].amount_to_claim.amount = parseInt( - // op[1].amount_to_claim.amount, - // 10 - // ); - // column = ( - // - // {this.linkToAccount(op[1].issuer)} - //   - // - // {({asset}) => ( - // - // )} - // - // - // ); - // break; - - // case "custom": - // column = ( - // - // - // - // ); - // break; - - // case "asset_reserve": - // column = ( - // - // - // - // ); - // break; - - // case "committee_member_update_global_parameters": - // console.log( - // "committee_member_update_global_parameters op:", - // op - // ); - // column = ( - // - // - // - // ); - // break; - - // case "override_transfer": - // column = ( - // - // ); - // break; - - // case "asset_settle_cancel": - // column = ( - // - // ); - // break; - - // case "asset_claim_pool": - // column = ( - // - // ); - // break; - - // case "asset_update_issuer": - // column = ( - // - // ); - // break; - - // case "bid_collateral": - // column = ( - // - // ); - // break; - - // default: - // console.log("unimplemented op '" + ops[op[0]] + "':", op); - // column = ( - // - // #{block} - // - // ); - // } - if (this.props.csvExportMode) { const globalObject = ChainStore.getObject("2.0.0"); const dynGlobalObject = ChainStore.getObject("2.1.0"); diff --git a/app/components/Blockchain/operations/AssetClaimPool.jsx b/app/components/Blockchain/operations/AssetClaimPool.jsx new file mode 100644 index 0000000000..f843f177d8 --- /dev/null +++ b/app/components/Blockchain/operations/AssetClaimPool.jsx @@ -0,0 +1,27 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetClaimPool = ({op}) => { + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/AssetFundFeePool.jsx b/app/components/Blockchain/operations/AssetFundFeePool.jsx index bea233099b..c50fd2e20c 100644 --- a/app/components/Blockchain/operations/AssetFundFeePool.jsx +++ b/app/components/Blockchain/operations/AssetFundFeePool.jsx @@ -2,27 +2,62 @@ import React from "react"; import Translate from "react-translate-component"; import {ChainStore} from "bitsharesjs"; import FormattedAsset from "../../Utility/FormattedAsset"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AssetFundFeePool = ({op, changeColor, linkToAccount}) => { +export const AssetFundFeePool = ({ + op, + changeColor, + linkToAccount, + fromComponent +}) => { changeColor("warning"); - - let asset = ChainStore.getAsset(op[1].asset_id); - if (asset) asset = asset.get("symbol"); - else asset = op[1].asset_id; - return ( - - {linkToAccount(op[1].from_account)}   - -   - - - ); + if (fromComponent === "proposed_operation") { + let asset = ChainStore.getAsset(op[1].asset_id); + if (asset) asset = asset.get("symbol"); + else asset = op[1].asset_id; + return ( + + {linkToAccount(op[1].from_account)}   + +   + + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AssetGlobalSettle.jsx b/app/components/Blockchain/operations/AssetGlobalSettle.jsx index c68d874d5b..826835db0d 100644 --- a/app/components/Blockchain/operations/AssetGlobalSettle.jsx +++ b/app/components/Blockchain/operations/AssetGlobalSettle.jsx @@ -1,28 +1,60 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedPrice from "../../Utility/FormattedPrice"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AssetGlobalSettle = ({op, changeColor, linkToAsset}) => { +export const AssetGlobalSettle = ({ + op, + changeColor, + linkToAsset, + fromComponent +}) => { changeColor("warning"); - - return ( - - -   - {linkToAsset(op[1].asset_to_settle)} -   - -   - - - ); + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAsset(op[1].asset_to_settle)} +   + +   + + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AssetIssue.jsx b/app/components/Blockchain/operations/AssetIssue.jsx index bf61dbfb5d..33301b100c 100644 --- a/app/components/Blockchain/operations/AssetIssue.jsx +++ b/app/components/Blockchain/operations/AssetIssue.jsx @@ -2,18 +2,22 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; import MemoText from "../MemoText"; -export const AssetIssue = ({op, changeColor}) => { +export const AssetIssue = ({op, changeColor, fromComponent}) => { changeColor("warning"); let memoComponent; if (op[1].memo) { memoComponent = ; } - op[1].asset_to_issue.amount = parseInt(op[1].asset_to_issue.amount, 10); + return ( { +export const AssetPublishFeed = ({ + op, + changeColor, + linkToAccount, + fromComponent +}) => { changeColor("warning"); - - return ( - - {linkToAccount(op[1].publisher)} -   - -   - - - ); + if (fromComponent === "proposed_operation") { + return ( + + {linkToAccount(op[1].publisher)} +   + +   + + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AssetReserve.jsx b/app/components/Blockchain/operations/AssetReserve.jsx index ecd20b4fd1..32a6e9e445 100644 --- a/app/components/Blockchain/operations/AssetReserve.jsx +++ b/app/components/Blockchain/operations/AssetReserve.jsx @@ -1,11 +1,15 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AssetReserve = ({op}) => { +export const AssetReserve = ({op, fromComponent}) => { return ( { +export const AssetSettle = ({op, result, changeColor, fromComponent}) => { changeColor("warning"); - - return ( - - - - ); + if (fromComponent === "proposed_operation") { + return ( + + + + ); + } else { + const baseAmount = op[1].amount; + const instantSettleCode = 2; + if (result && result[0] == instantSettleCode) { + const quoteAmount = result[1]; + return ( + + + + ); + } else { + return ( + + + + ); + } + } }; diff --git a/app/components/Blockchain/operations/AssetSettleCancel.jsx b/app/components/Blockchain/operations/AssetSettleCancel.jsx new file mode 100644 index 0000000000..6ccbf09e7a --- /dev/null +++ b/app/components/Blockchain/operations/AssetSettleCancel.jsx @@ -0,0 +1,18 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetSettleCancel = ({op}) => { + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx b/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx index c2dfc3f4d1..1dba011b7b 100644 --- a/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx +++ b/app/components/Blockchain/operations/AssetUpdateFeedProducers.jsx @@ -1,24 +1,46 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const AssetUpdateFeedProducers = ({op, changeColor}) => { +export const AssetUpdateFeedProducers = ({op, changeColor, fromComponent}) => { changeColor("warning"); - return ( - - ); + if (fromComponent === "proposed_operation") { + return ( + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/AssetUpdateIssuer.jsx b/app/components/Blockchain/operations/AssetUpdateIssuer.jsx new file mode 100644 index 0000000000..ae4e0edb26 --- /dev/null +++ b/app/components/Blockchain/operations/AssetUpdateIssuer.jsx @@ -0,0 +1,27 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const AssetUpdateIssuer = ({op}) => { + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/BalanceClaim.jsx b/app/components/Blockchain/operations/BalanceClaim.jsx index 2f5f3bc36d..3e7e812e90 100644 --- a/app/components/Blockchain/operations/BalanceClaim.jsx +++ b/app/components/Blockchain/operations/BalanceClaim.jsx @@ -2,28 +2,56 @@ import React from "react"; import Translate from "react-translate-component"; import BindToChainState from "../../Utility/BindToChainState"; import utils from "common/utils"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const BalanceClaim = ({op, changeColor, linkToAccount}) => { +export const BalanceClaim = ({ + op, + changeColor, + linkToAccount, + fromComponent +}) => { changeColor("success"); op[1].total_claimed.amount = parseInt(op[1].total_claimed.amount, 10); - return ( - - {linkToAccount(op[1].deposit_to_account)} -   - - {({asset}) => ( - - )} - - - ); + if (fromComponent === "proposed_operation") { + return ( + + {linkToAccount(op[1].deposit_to_account)} +   + + {({asset}) => ( + + )} + + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/BidCollateral.jsx b/app/components/Blockchain/operations/BidCollateral.jsx new file mode 100644 index 0000000000..6735b668ca --- /dev/null +++ b/app/components/Blockchain/operations/BidCollateral.jsx @@ -0,0 +1,27 @@ +import React from "react"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; + +export const BidCollateral = ({op}) => { + return ( + + ); +}; diff --git a/app/components/Blockchain/operations/BondAcceptOffer.jsx b/app/components/Blockchain/operations/BondAcceptOffer.jsx index 7d33e098a5..b3048fe3f5 100644 --- a/app/components/Blockchain/operations/BondAcceptOffer.jsx +++ b/app/components/Blockchain/operations/BondAcceptOffer.jsx @@ -2,7 +2,7 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedAsset from "../../Utility/FormattedAsset"; -export const BondAcceptOffer = ({op, linkToAccount}) => { +export const BondAcceptOffer = ({op, linkToAccount, current}) => { if (current === op[1].lender) { return ( diff --git a/app/components/Blockchain/operations/BondClaimCollaterial.jsx b/app/components/Blockchain/operations/BondClaimCollaterial.jsx index fec9b5a9e9..077bae13a2 100644 --- a/app/components/Blockchain/operations/BondClaimCollaterial.jsx +++ b/app/components/Blockchain/operations/BondClaimCollaterial.jsx @@ -2,7 +2,7 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedAsset from "../../Utility/FormattedAsset"; -export const BondClaimCollaterial = ({op, linkToAccount}) => { +export const BondClaimCollaterial = ({op, linkToAccount, current}) => { if (current === op[1].lender) { return ( diff --git a/app/components/Blockchain/operations/CallOrderUpdate.jsx b/app/components/Blockchain/operations/CallOrderUpdate.jsx index 9a5b480c4f..d109dc1bd1 100644 --- a/app/components/Blockchain/operations/CallOrderUpdate.jsx +++ b/app/components/Blockchain/operations/CallOrderUpdate.jsx @@ -1,13 +1,17 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const CallOrderUpdate = ({op, changeColor}) => { +export const CallOrderUpdate = ({op, changeColor, fromComponent}) => { changeColor("warning"); return ( { +export const CommitteeMemberUpdateGlobalParams = ({fromComponent}) => { return ( { +export const CommittyMemberCreate = ({op, linkToAccount, fromComponent}) => { return (   {linkToAccount(op[1].committee_member_account)} diff --git a/app/components/Blockchain/operations/Custom.jsx b/app/components/Blockchain/operations/Custom.jsx index b0883de0b4..d8ced1d40a 100644 --- a/app/components/Blockchain/operations/Custom.jsx +++ b/app/components/Blockchain/operations/Custom.jsx @@ -1,10 +1,17 @@ import React from "react"; import Translate from "react-translate-component"; -export const Custom = () => { +export const Custom = ({fromComponent}) => { return ( - + ); }; diff --git a/app/components/Blockchain/operations/FillOrder.jsx b/app/components/Blockchain/operations/FillOrder.jsx index 33629e09c6..0dd4873c05 100644 --- a/app/components/Blockchain/operations/FillOrder.jsx +++ b/app/components/Blockchain/operations/FillOrder.jsx @@ -1,39 +1,114 @@ +/* eslint-disable react/display-name */ import React from "react"; import Translate from "react-translate-component"; import FormattedAsset from "../../Utility/FormattedAsset"; import FormattedPrice from "../../Utility/FormattedPrice"; +import BindToChainState from "../../Utility/BindToChainState"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; +import marketUtils from "common/market_utils"; -export const FillOrder = ({changeColor, op, linkToAccount}) => { +export const FillOrder = ({ + changeColor, + op, + linkToAccount, + marketDirections, + fromComponent +}) => { changeColor("success"); const o = op[1]; - return ( - - {linkToAccount(op.account_id)} -   - -   - -   - -   - -   - -   - - - ); + if (fromComponent === "proposed_operation") { + return ( + + {linkToAccount(op.account_id)} +   + +   + +   + +   + +   + +   + + + ); + } else { + return ( + + + {({base, quote}) => { + const { + marketName, + first, + second + } = marketUtils.getMarketName(base, quote); + const inverted = marketDirections.get(marketName); + const isBid = + o.pays.asset_id === + (inverted ? first.get("id") : second.get("id")); + + let priceBase = isBid ? o.receives : o.pays; + let priceQuote = isBid ? o.pays : o.receives; + let amount = isBid ? o.receives : o.pays; + let receivedAmount = + o.fee.asset_id === amount.asset_id + ? amount.amount - o.fee.amount + : amount.amount; + + return ( + + ); + }} + + + ); + } }; diff --git a/app/components/Blockchain/operations/GlobalParametersUpdate.jsx b/app/components/Blockchain/operations/GlobalParametersUpdate.jsx index f5e2d93099..8e4fa6956a 100644 --- a/app/components/Blockchain/operations/GlobalParametersUpdate.jsx +++ b/app/components/Blockchain/operations/GlobalParametersUpdate.jsx @@ -1,12 +1,16 @@ import React from "react"; import Translate from "react-translate-component"; -export const GlobalParametersUpdate = () => { +export const GlobalParametersUpdate = ({fromComponent}) => { return ( ); diff --git a/app/components/Blockchain/operations/LimitOrderCancel.jsx b/app/components/Blockchain/operations/LimitOrderCancel.jsx index 50111c8adb..2935b6dac4 100644 --- a/app/components/Blockchain/operations/LimitOrderCancel.jsx +++ b/app/components/Blockchain/operations/LimitOrderCancel.jsx @@ -2,13 +2,18 @@ import React from "react"; import Translate from "react-translate-component"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const LimitOrderCancel = ({op, changeColor, fromComponent}) => { +export const LimitOrderCancel = ({ + op, + changeColor, + fromComponent, + linkToAccount +}) => { changeColor("cancel"); if (fromComponent === "proposed_operation") { return ( - {this.linkToAccount(op[1].fee_paying_account)} + {linkToAccount(op[1].fee_paying_account)}   { +import marketUtils from "common/market_utils"; +export const LimitOrderCreate = ({ + op, + changeColor, + fromComponent, + marketDirections, + result +}) => { changeColor("warning"); if (fromComponent === "proposed_operation") { @@ -60,9 +66,7 @@ export const LimitOrderCreate = ({op, changeColor, fromComponent}) => { first, second } = marketUtils.getMarketName(base, quote); - const inverted = this.props.marketDirections.get( - marketName - ); + const inverted = marketDirections.get(marketName); const isBid = o.amount_to_sell.asset_id === @@ -77,9 +81,9 @@ export const LimitOrderCreate = ({op, changeColor, fromComponent}) => { const amount = isBid ? op[1].min_to_receive : op[1].amount_to_sell; - let orderId = this.props.result - ? typeof this.props.result[1] == "string" - ? "#" + this.props.result[1].substring(4) + let orderId = result + ? typeof result[1] == "string" + ? "#" + result[1].substring(4) : "" : ""; diff --git a/app/components/Blockchain/operations/OverrideTransfer.jsx b/app/components/Blockchain/operations/OverrideTransfer.jsx index 77806830e3..bed0ef4dd2 100644 --- a/app/components/Blockchain/operations/OverrideTransfer.jsx +++ b/app/components/Blockchain/operations/OverrideTransfer.jsx @@ -1,10 +1,14 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const OverrideTransfer = ({op}) => { +export const OverrideTransfer = ({op, fromComponent}) => { return ( { - return ( - - - - ); +const ShortObjectId = ({objectId}) => { + if (typeof objectId === "string") { + const parts = objectId.split("."); + const {length} = parts; + if (length > 0) return "#" + parts[length - 1]; + } + return objectId; +}; + +export const ProposalDelete = ({op, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + + + ); + } else { + return ( + + , + arg: "proposal" + } + ]} + /> + + ); + } }; diff --git a/app/components/Blockchain/operations/ProposalUpdate.jsx b/app/components/Blockchain/operations/ProposalUpdate.jsx index c2bc35c340..5e663d5642 100644 --- a/app/components/Blockchain/operations/ProposalUpdate.jsx +++ b/app/components/Blockchain/operations/ProposalUpdate.jsx @@ -1,10 +1,80 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const ProposalUpdate = () => { - return ( - - - - ); +const ShortObjectId = ({objectId}) => { + if (typeof objectId === "string") { + const parts = objectId.split("."); + const {length} = parts; + if (length > 0) return "#" + parts[length - 1]; + } + return objectId; +}; + +export const ProposalUpdate = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + + + ); + } else { + const fields = [ + "active_approvals_to_add", + "active_approvals_to_remove", + "owner_approvals_to_add", + "owner_approvals_to_remove", + "key_approvals_to_add", + "key_approvals_to_remove" + ]; + return ( +
+ + + ), + arg: "proposal" + } + ]} + /> + +
+ {fields.map(field => { + if (op[1][field].length) { + return ( +
+ +
    + {op[1][field].map(value => { + return ( +
  • + {field.startsWith("key") + ? value + : linkToAccount(value)} +
  • + ); + })} +
+
+ ); + } else return null; + })} +
+
+ ); + } }; diff --git a/app/components/Blockchain/operations/TransferFromBlind.jsx b/app/components/Blockchain/operations/TransferFromBlind.jsx index 4a4152559e..6d30597880 100644 --- a/app/components/Blockchain/operations/TransferFromBlind.jsx +++ b/app/components/Blockchain/operations/TransferFromBlind.jsx @@ -2,12 +2,19 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedAsset from "../../Utility/FormattedAsset"; -export const TransferFromBlind = ({op, linkToAccount}) => { +export const TransferFromBlind = ({op, linkToAccount, fromComponent}) => { return ( {linkToAccount(op[1].to)}   - +   { +export const TransferToBlind = ({op, linkToAccount, fromComponent}) => { return ( {linkToAccount(op[1].from)}   - +   { - return ( - -   - {linkToAccount(op[1].creator)} - -   - -   - {linkToAccount(op[1].owner)} - - ); +export const VestingBalanceCreate = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + +   + {linkToAccount(op[1].creator)} + +   + +   + {linkToAccount(op[1].owner)} + + ); + } else { + return ( + +   + {linkToAccount(op[1].creator)} + +   + +   + {linkToAccount(op[1].owner)} + + ); + } }; diff --git a/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx b/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx index 7c71d64f1c..8223047ee9 100644 --- a/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx +++ b/app/components/Blockchain/operations/VestingBalanceWithdraw.jsx @@ -1,10 +1,14 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const VestingBalanceWithdraw = ({op}) => { +export const VestingBalanceWithdraw = ({op, fromComponent}) => { return ( { - return ( - - -   - {linkToAccount(op[1].withdraw_from_account)} - -   - {linkToAccount(op[1].withdraw_to_account)} - - ); +export const WithdrawPermissionClaim = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].withdraw_to_account)} + + ); + } else { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].withdraw_to_account)} + + ); + } }; diff --git a/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx b/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx index 201a345b36..a098699791 100644 --- a/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx +++ b/app/components/Blockchain/operations/WithdrawPermissionCreate.jsx @@ -1,18 +1,38 @@ import React from "react"; import Translate from "react-translate-component"; -export const WithdrawPermissionCreate = ({op, linkToAccount}) => { - return ( - - -   - {linkToAccount(op[1].withdraw_from_account)} - -   - {linkToAccount(op[1].authorized_account)} - - ); +export const WithdrawPermissionCreate = ({ + op, + linkToAccount, + fromComponent +}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); + } else { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); + } }; diff --git a/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx b/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx index c74f44306b..b1bef66bbb 100644 --- a/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx +++ b/app/components/Blockchain/operations/WithdrawPermissionDelete.jsx @@ -1,18 +1,38 @@ import React from "react"; import Translate from "react-translate-component"; -export const WithdrawPermissionDelete = ({op, linkToAccount}) => { - return ( - - -   - {linkToAccount(op[1].withdraw_from_account)} - -   - {linkToAccount(op[1].authorized_account)} - - ); +export const WithdrawPermissionDelete = ({ + op, + linkToAccount, + fromComponent +}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); + } else { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); + } }; diff --git a/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx b/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx index a45ccdb9f4..a58b77dfd3 100644 --- a/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx +++ b/app/components/Blockchain/operations/WithdrawPermissionUpdate.jsx @@ -1,18 +1,38 @@ import React from "react"; import Translate from "react-translate-component"; -export const WithdrawPermissionUpdate = ({op, linkToAccount}) => { - return ( - - -   - {linkToAccount(op[1].withdraw_from_account)} - -   - {linkToAccount(op[1].authorized_account)} - - ); +export const WithdrawPermissionUpdate = ({ + op, + linkToAccount, + fromComponent +}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); + } else { + return ( + + +   + {linkToAccount(op[1].withdraw_from_account)} + +   + {linkToAccount(op[1].authorized_account)} + + ); + } }; diff --git a/app/components/Blockchain/operations/WitnessCreate.jsx b/app/components/Blockchain/operations/WitnessCreate.jsx index 3df6a1ab31..37b652d946 100644 --- a/app/components/Blockchain/operations/WitnessCreate.jsx +++ b/app/components/Blockchain/operations/WitnessCreate.jsx @@ -1,12 +1,30 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const WitnessCreate = ({op, linkToAccount}) => { - return ( - - -   - {linkToAccount(op[1].witness_account)} - - ); +export const WitnessCreate = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].witness_account)} + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/WitnessUpdate.jsx b/app/components/Blockchain/operations/WitnessUpdate.jsx index 45d1fb8797..1f6538891c 100644 --- a/app/components/Blockchain/operations/WitnessUpdate.jsx +++ b/app/components/Blockchain/operations/WitnessUpdate.jsx @@ -1,12 +1,30 @@ import React from "react"; import Translate from "react-translate-component"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const WitnessUpdate = ({op, linkToAccount}) => { - return ( - - -   - {linkToAccount(op[1].witness_account)} - - ); +export const WitnessUpdate = ({op, linkToAccount, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + {linkToAccount(op[1].witness_account)} + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/WitnessWithdrawPay.jsx b/app/components/Blockchain/operations/WitnessWithdrawPay.jsx index c4f02ef5a5..d1919dfbd8 100644 --- a/app/components/Blockchain/operations/WitnessWithdrawPay.jsx +++ b/app/components/Blockchain/operations/WitnessWithdrawPay.jsx @@ -2,36 +2,76 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedAsset from "../../Utility/FormattedAsset"; -export const WitnessWithdrawPay = ({op, current, linkToAccount}) => { - if (current === op[1].witness_account) { - return ( - - -   - - -   - {linkToAccount(op[1].witness_account)} - - ); +export const WitnessWithdrawPay = ({ + op, + current, + linkToAccount, + fromComponent +}) => { + if (fromComponent === "proposed_operation") { + if (current === op[1].witness_account) { + return ( + + +   + + +   + {linkToAccount(op[1].witness_account)} + + ); + } else { + return ( + + +   + + +   + {linkToAccount(op[1].witness_account)} + + ); + } } else { - return ( - - -   - - -   - {linkToAccount(op[1].witness_account)} - - ); + if (current === op[1].witness_account) { + return ( + + +   + + +   + {linkToAccount(op[1].witness_account)} + + ); + } else { + return ( + + +   + + +   + {linkToAccount(op[1].witness_account)} + + ); + } } }; diff --git a/app/components/Blockchain/operations/WorkerCreate.jsx b/app/components/Blockchain/operations/WorkerCreate.jsx index 866e903374..ab604bffc6 100644 --- a/app/components/Blockchain/operations/WorkerCreate.jsx +++ b/app/components/Blockchain/operations/WorkerCreate.jsx @@ -1,17 +1,46 @@ import React from "react"; import Translate from "react-translate-component"; import FormattedAsset from "../../Utility/FormattedAsset"; +import TranslateWithLinks from "../../Utility/TranslateWithLinks"; -export const WorkerCreate = ({op}) => { - return ( - - -   - - - ); +export const WorkerCreate = ({op, fromComponent}) => { + if (fromComponent === "proposed_operation") { + return ( + + +   + + + ); + } else { + return ( + + + + ); + } }; diff --git a/app/components/Blockchain/operations/index.js b/app/components/Blockchain/operations/index.js index 5779d3d6f7..a45ba06094 100644 --- a/app/components/Blockchain/operations/index.js +++ b/app/components/Blockchain/operations/index.js @@ -17,8 +17,11 @@ import {AssetIssue} from "./AssetIssue"; import {AssetReserve} from "./AssetReserve"; import {AssetFundFeePool} from "./AssetFundFeePool"; import {AssetSettle} from "./AssetSettle"; +import {AssetSettleCancel} from "./AssetSettleCancel"; import {AssetGlobalSettle} from "./AssetGlobalSettle"; import {AssetPublishFeed} from "./AssetPublishFeed"; +import {AssetClaimPool} from "./AssetClaimPool"; +import {AssetUpdateIssuer} from "./AssetUpdateIssuer"; import {WitnessCreate} from "./WitnessCreate"; import {WitnessUpdate} from "./WitnessUpdate"; import {WitnessWithdrawPay} from "./WitnessWithdrawPay"; @@ -48,43 +51,26 @@ import {CommitteeMemberUpdateGlobalParams} from "./CommitteeMemberUpdateGlobalPa import {Custom} from "./Custom"; import {OverrideTransfer} from "./OverrideTransfer"; import {DefaultOperation} from "./DefaultOperation"; +import {BidCollateral} from "./BidCollateral"; export default function opComponents(opType, props, opts) { - console.log("** operation params**", {opType, props, opts}); - switch (opType) { case "transfer": - return ; + return ; break; case "limit_order_create": - return ( - - ); + return ; break; case "limit_order_cancel": - return ( - - ); + return ; break; case "short_order_cancel": - return ( - - ); + return ; break; case "call_order_update": - return ( - - ); + return ; break; case "key_create": @@ -92,199 +78,122 @@ export default function opComponents(opType, props, opts) { break; case "account_create": - return ( - - ); + return ; break; case "account_update": - return ( - - ); + return ; break; case "account_whitelist": - return ( - - ); + return ; break; case "account_upgrade": - return ( - - ); + return ; break; case "account_transfer": - return ( - - ); + return ; break; case "asset_create": - return ( - - ); + return ; break; case "asset_update": case "asset_update_bitasset": - return ( - - ); + return ; break; - + /* -------------------------------------------------------------------------------------------- */ case "asset_update_feed_producers": - return ( - - ); + return ; break; case "asset_issue": - return ; + return ; break; case "asset_reserve": - return ; + return ; break; case "asset_fund_fee_pool": - return ( - - ); + return ; break; case "asset_settle": - return ; + return ; + break; + + case "asset_settle_cancel": + return ; break; case "asset_global_settle": - return ( - - ); + return ; break; case "asset_publish_feed": - return ( - - ); + return ; break; - case "witness_create": - return ( - - ); + case "asset_claim_pool": + return ; + break; + case "asset_update_issuer": + return ; + break; + + case "witness_create": + return ; break; case "witness_update": - return ; + return ; break; case "witness_withdraw_pay": - return ( - - ); + return ; break; case "proposal_create": - return ( - - ); + return ; break; case "proposal_update": - return ; + return ; break; case "proposal_delete": - return ; + return ; break; case "withdraw_permission_create": - return ( - - ); + return ; break; case "withdraw_permission_update": - return ( - - ); + return ; break; case "withdraw_permission_claim": - return ( - - ); + return ; break; case "withdraw_permission_delete": - return ; + return ; break; case "fill_order": - return ( - - ); + return ; break; case "global_parameters_update": - return ; + return ( + + ); break; case "file_write": @@ -292,16 +201,11 @@ export default function opComponents(opType, props, opts) { break; case "vesting_balance_create": - return ( - - ); + return ; break; case "vesting_balance_withdraw": - return ; + return ; break; case "bond_create_offer": @@ -313,84 +217,55 @@ export default function opComponents(opType, props, opts) { break; case "bond_accept_offer": - return ( - - ); + return ; break; case "bond_claim_collateral": - return ( - - ); + return ; break; case "worker_create": - return ; + return ; break; case "balance_claim": - return ( - - ); + return ; break; case "committee_member_create": - return ( - - ); + return ; break; case "transfer_to_blind": - return ( - - ); + return ; break; case "transfer_from_blind": - return ( - - ); + return ; break; case "asset_claim_fees": - return ( - - ); + return ; break; case "committee_member_update_global_parameters": - return ; + return ( + + ); break; case "custom": - return ; + return ; break; case "override_transfer": - return ; + return ; + break; + + case "bid_collateral": + return ; break; default: From fa3057f336366c7f7c299738b233a6bf0cd148a8 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Tue, 9 Apr 2019 13:42:12 +0300 Subject: [PATCH 07/12] added votes and memo keys displaying --- app/assets/locales/locale-en.json | 7 +- .../Blockchain/operations/AccountUpdate.jsx | 84 +++++++++++++++++++ app/components/Utility/TranslateWithLinks.jsx | 40 ++++++++- 3 files changed, 128 insertions(+), 3 deletions(-) diff --git a/app/assets/locales/locale-en.json b/app/assets/locales/locale-en.json index d4118a2dc9..ef57eece5d 100644 --- a/app/assets/locales/locale-en.json +++ b/app/assets/locales/locale-en.json @@ -1587,12 +1587,14 @@ "call_order_update": "Change {account} {debtSymbol} debt by {debt} and collateral by {collateral}", "committee_member_update_global_parameters": "Update committee global parameters by {account}", "delete": "Permanently reject", + "danger_operation": "Dangerous operation!", "expires": "Expires", "feed_producer": "Update the feed producers for the asset {asset} using the account {account}", "limit_order_buy": "Place an order to buy {amount} at {price} for {account}", "limit_order_create": "Place an order to buy %(buy_amount)s for %(sell_amount)s for %(account)s", "limit_order_sell": "Place an order to sell {amount} at {price} for {account}", "override_transfer": "Transfer {amount} from {from} to {to} by authority of {issuer}", + "public_key": "Public key", "proposals": "Proposals", "reject": "Reject", "status": "Status", @@ -1605,7 +1607,7 @@ "owner_approvals_to_add": "Owner approvals to add", "owner_approvals_to_remove": "Owner approvals to remove" }, - "update_account": "Update account data for {account}", + "update_account": "Update account data for {account} {memo}", "updated": { "active_approvals_to_add": "Active approval(s) added", "active_approvals_to_remove": "Active approval(s) removed", @@ -1614,7 +1616,8 @@ "owner_approvals_to_add": "Owner approval(s) added", "owner_approvals_to_remove": "Owner approval(s) removed" }, - "vesting_balance_withdraw": "Withdraw {amount} from vesting balance of {account}" + "vesting_balance_withdraw": "Withdraw {amount} from vesting balance of {account}", + "votes": "Votes" }, "proposal_create": { "expiration_time": "Expiration time", diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx index f614243f4c..5caf55a098 100644 --- a/app/components/Blockchain/operations/AccountUpdate.jsx +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -1,7 +1,86 @@ import React from "react"; import TranslateWithLinks from "../../Utility/TranslateWithLinks"; +import {ChainStore} from "bitsharesjs"; + +const compareKeys = (prev, next) => { + let minus = prev.filter(x => !next.includes(x)); + let plus = next.filter(x => !prev.includes(x)); + + return {minus, plus}; +}; export const AccountUpdate = ({op, fromComponent}) => { + const { + owner: {key_auth: owner} = [], + active: {key_auth: active} = [], + new_options: {memo_key, votes}, + account + } = op[1]; + + let change = {}; + let votesPlusNames = []; + let votesMinusNames = []; + + if (fromComponent === "proposed_operation") { + const _account = ChainStore.getAccount(account, false); + const _votes = _account + .get("options") + .get("votes") + .toArray(); + + const votesIds = compareKeys(_votes, votes); + const votesPlusData = ChainStore.getObjectsByVoteIds(votesIds.plus); + const votesMinusData = ChainStore.getObjectsByVoteIds(votesIds.minus); + + if (votesPlusData && votesMinusData) { + votesPlusData.forEach(item => { + if (item) { + const id = + item.get("witness_account") || + item.get("committee_member_account"); + const name = id + ? ChainStore.getAccountName(id) || id + : null; + if (name) votesPlusNames.push(name); + } + }); + votesMinusData.forEach(item => { + if (item) { + const id = + item.get("witness_account") || + item.get("committee_member_account"); + const name = id + ? ChainStore.getAccountName(id) || id + : null; + if (name) votesMinusNames.push(name); + } + }); + change.votes = {minus: votesMinusNames, plus: votesPlusNames}; + } + + if (owner) { + const _owner = _account + .get("active") + .get("key_auths") + .map(a => a.get(0)) + .toArray(); + change.keys = {...change.keys, ...compareKeys(_owner, owner[0])}; + } + if (active) { + const _active = _account + .get("active") + .get("key_auths") + .map(a => a.get(0)) + .toArray(); + change.keys = {...change.keys, ...compareKeys(_active, active[0])}; + } + + if (memo_key) { + const _memo = _account.get("options").get("memo_key"); + change.keys = {...change.keys, ...compareKeys([_memo], [memo_key])}; + } + } + return ( { type: "account", value: op[1].account, arg: "account" + }, + { + type: "memo", + value: change, + arg: "memo" } ]} /> diff --git a/app/components/Utility/TranslateWithLinks.jsx b/app/components/Utility/TranslateWithLinks.jsx index d582d4bd6a..9f4ae4f12a 100644 --- a/app/components/Utility/TranslateWithLinks.jsx +++ b/app/components/Utility/TranslateWithLinks.jsx @@ -88,7 +88,8 @@ export default class TranslateWithLinks extends React.Component { asset={key.value.asset_id} decimalOffset={key.decimalOffset} hide_asset - />  + /> +   {this.linkToAsset(key.value.asset_id)} ); @@ -138,6 +139,43 @@ export default class TranslateWithLinks extends React.Component { ); break; + case "memo": + const {votes, keys} = key.value; + value = + key.value && (votes || keys) ? ( + + {votes.minus.length || votes.plus.length ? ( +
+ +
+ ) : null} + {votes.minus.length ? ( +
- {votes.minus.join(", ")}
+ ) : null} + {votes.plus.length ? ( +
+ {votes.plus.join(", ")}
+ ) : null} + {keys.plus.length ? ( +
+ +
+ {keys.plus.join(", ")}
+
- {keys.minus.join(", ")}
+ +
+ ) : null} +
+ ) : null; + break; + default: value = key.value; break; From 8a000fb40c42ae1caf9af075bb365b1e7ff75ab5 Mon Sep 17 00:00:00 2001 From: Stefan Schiessl Date: Tue, 16 Apr 2019 15:39:54 +0200 Subject: [PATCH 08/12] fix active owner and change handling Signed-off-by: Stefan Schiessl --- app/assets/locales/locale-en.json | 6 +- .../Blockchain/operations/AccountUpdate.jsx | 86 +++++++++++-------- .../Blockchain/operations/Transfer.jsx | 15 ---- app/components/Utility/TranslateWithLinks.jsx | 41 ++++++--- 4 files changed, 78 insertions(+), 70 deletions(-) diff --git a/app/assets/locales/locale-en.json b/app/assets/locales/locale-en.json index f519f33f87..e67caca73e 100644 --- a/app/assets/locales/locale-en.json +++ b/app/assets/locales/locale-en.json @@ -1562,7 +1562,7 @@ "transfer": "{from} sent {amount} to {to}", "transfer_account": "{account} ownership transferred to {to}", "unlisted_by": "{lister} unlisted the account {listee}", - "update_account": "{account} updated their account data", + "update_account": "{account} updated their account data {change}", "vesting_balance_withdraw": "{account} withdrew vesting balance of {amount}", "whitelisted_by": "{lister} whitelisted the account {listee}", "witness_create": "{account} was upgraded to become a witness", @@ -1601,7 +1601,7 @@ "limit_order_create": "Place an order to buy %(buy_amount)s for %(sell_amount)s for %(account)s", "limit_order_sell": "Place an order to sell {amount} at {price} for {account}", "override_transfer": "Transfer {amount} from {from} to {to} by authority of {issuer}", - "public_key": "Public key", + "public_key": "Key changes", "proposals": "Proposals", "reject": "Reject", "status": "Status", @@ -1614,7 +1614,7 @@ "owner_approvals_to_add": "Owner approvals to add", "owner_approvals_to_remove": "Owner approvals to remove" }, - "update_account": "Update account data for {account} {memo}", + "update_account": "Update account data for {account} {change}", "updated": { "active_approvals_to_add": "Active approval(s) added", "active_approvals_to_remove": "Active approval(s) removed", diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx index 5caf55a098..32d3237bc1 100644 --- a/app/components/Blockchain/operations/AccountUpdate.jsx +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -10,12 +10,13 @@ const compareKeys = (prev, next) => { }; export const AccountUpdate = ({op, fromComponent}) => { - const { - owner: {key_auth: owner} = [], - active: {key_auth: active} = [], - new_options: {memo_key, votes}, - account - } = op[1]; + const account = op[1].account; + + const votes = op[1].new_options ? op[1].new_options.votes : undefined; + const memo_key = op[1].new_options ? op[1].new_options.memo_key : undefined; + + const owner = op[1].owner ? op[1].owner : undefined; + const active = op[1].active ? op[1].active : undefined; let change = {}; let votesPlusNames = []; @@ -28,34 +29,37 @@ export const AccountUpdate = ({op, fromComponent}) => { .get("votes") .toArray(); - const votesIds = compareKeys(_votes, votes); - const votesPlusData = ChainStore.getObjectsByVoteIds(votesIds.plus); - const votesMinusData = ChainStore.getObjectsByVoteIds(votesIds.minus); - - if (votesPlusData && votesMinusData) { - votesPlusData.forEach(item => { - if (item) { - const id = - item.get("witness_account") || - item.get("committee_member_account"); - const name = id - ? ChainStore.getAccountName(id) || id - : null; - if (name) votesPlusNames.push(name); - } - }); - votesMinusData.forEach(item => { - if (item) { - const id = - item.get("witness_account") || - item.get("committee_member_account"); - const name = id - ? ChainStore.getAccountName(id) || id - : null; - if (name) votesMinusNames.push(name); - } - }); - change.votes = {minus: votesMinusNames, plus: votesPlusNames}; + if (votes) { + const votesIds = compareKeys(_votes, votes); + const votesPlusData = ChainStore.getObjectsByVoteIds(votesIds.plus); + const votesMinusData = ChainStore.getObjectsByVoteIds( + votesIds.minus + ); + if (votesPlusData && votesMinusData) { + votesPlusData.forEach(item => { + if (item) { + const id = + item.get("witness_account") || + item.get("committee_member_account"); + const name = id + ? ChainStore.getAccountName(id) || id + : null; + if (name) votesPlusNames.push(name); + } + }); + votesMinusData.forEach(item => { + if (item) { + const id = + item.get("witness_account") || + item.get("committee_member_account"); + const name = id + ? ChainStore.getAccountName(id) || id + : null; + if (name) votesMinusNames.push(name); + } + }); + change.votes = {minus: votesMinusNames, plus: votesPlusNames}; + } } if (owner) { @@ -64,7 +68,10 @@ export const AccountUpdate = ({op, fromComponent}) => { .get("key_auths") .map(a => a.get(0)) .toArray(); - change.keys = {...change.keys, ...compareKeys(_owner, owner[0])}; + change.keys = { + ...change.keys, + ...compareKeys(_owner, owner.key_auths.map(x => x[0])) + }; } if (active) { const _active = _account @@ -72,7 +79,10 @@ export const AccountUpdate = ({op, fromComponent}) => { .get("key_auths") .map(a => a.get(0)) .toArray(); - change.keys = {...change.keys, ...compareKeys(_active, active[0])}; + change.keys = { + ...change.keys, + ...compareKeys(_active, active.key_auths.map(x => x[0])) + }; } if (memo_key) { @@ -96,9 +106,9 @@ export const AccountUpdate = ({op, fromComponent}) => { arg: "account" }, { - type: "memo", + type: "change", value: change, - arg: "memo" + arg: "change" } ]} /> diff --git a/app/components/Blockchain/operations/Transfer.jsx b/app/components/Blockchain/operations/Transfer.jsx index aa7f9d5e85..eef6e5bfc5 100644 --- a/app/components/Blockchain/operations/Transfer.jsx +++ b/app/components/Blockchain/operations/Transfer.jsx @@ -14,21 +14,6 @@ export const Transfer = ({op, proposer, index, changeColor}) => { return (
- {!!proposer && index == 0 ? ( -
- - : -
- ) : null}
- {votes.minus.length || votes.plus.length ? ( + {votes && + (votes.minus.length || + votes.plus.length) ? (
+ {votes && votes.minus.length ? ( +
+ - {votes.minus.join(", ")} +
+ ) : null} + {votes && votes.plus.length ? ( +
+ + {votes.plus.join(", ")} +
+ ) : null}
) : null} - {votes.minus.length ? ( -
- {votes.minus.join(", ")}
- ) : null} - {votes.plus.length ? ( -
+ {votes.plus.join(", ")}
- ) : null} - {keys.plus.length ? ( + {keys && + (keys.minus.length || keys.plus.length) ? (
-
+ {keys.plus.join(", ")}
-
- {keys.minus.join(", ")}
+
+ {keys.plus.join(", ")}
+
+ {" "} + - {keys.minus.join(", ")} +
) : null} - ) : null; + ); + } else { + value = ""; + } break; default: From 55528d63354844e01cad6745b7cb438ac6f790a0 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Thu, 18 Apr 2019 04:15:37 +0300 Subject: [PATCH 09/12] added worker name --- .../Blockchain/operations/AccountUpdate.jsx | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx index 32d3237bc1..e7bd68483a 100644 --- a/app/components/Blockchain/operations/AccountUpdate.jsx +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -9,6 +9,16 @@ const compareKeys = (prev, next) => { return {minus, plus}; }; +const getVotesName = item => { + const id = + item.get("witness_account") || item.get("committee_member_account"); + return id + ? ChainStore.getAccountName(id) || id + : item.get("worker") + ? item.get("name") + : null; +}; + export const AccountUpdate = ({op, fromComponent}) => { const account = op[1].account; @@ -35,26 +45,17 @@ export const AccountUpdate = ({op, fromComponent}) => { const votesMinusData = ChainStore.getObjectsByVoteIds( votesIds.minus ); + if (votesPlusData && votesMinusData) { votesPlusData.forEach(item => { if (item) { - const id = - item.get("witness_account") || - item.get("committee_member_account"); - const name = id - ? ChainStore.getAccountName(id) || id - : null; + const name = getVotesName(item); if (name) votesPlusNames.push(name); } }); votesMinusData.forEach(item => { if (item) { - const id = - item.get("witness_account") || - item.get("committee_member_account"); - const name = id - ? ChainStore.getAccountName(id) || id - : null; + const name = getVotesName(item); if (name) votesMinusNames.push(name); } }); From 063df95fc12dc5fa81b3b98d8ed0f3edfe2b4f20 Mon Sep 17 00:00:00 2001 From: VerevkinAlexander Date: Thu, 18 Apr 2019 16:36:30 +0300 Subject: [PATCH 10/12] fix issue with rendering Activity tab --- app/components/Account/RecentTransactions.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/components/Account/RecentTransactions.jsx b/app/components/Account/RecentTransactions.jsx index 481c9c14dc..0405f10944 100644 --- a/app/components/Account/RecentTransactions.jsx +++ b/app/components/Account/RecentTransactions.jsx @@ -6,6 +6,7 @@ import ChainTypes from "../Utility/ChainTypes"; import BindToChainState from "../Utility/BindToChainState"; import utils from "common/utils"; import {ChainTypes as grapheneChainTypes, FetchChain} from "bitsharesjs"; +import {ChainStore} from "bitsharesjs"; import ps from "perfect-scrollbar"; import counterpart from "counterpart"; import Icon from "../Icon/Icon"; @@ -57,6 +58,7 @@ class RecentTransactions extends React.Component { filter: "all", accountHistoryError: false }; + this.forceUpdate = this.forceUpdate.bind(this); } componentDidMount() { @@ -66,6 +68,7 @@ class RecentTransactions extends React.Component { this._setHeaderHeight(); } + ChainStore.subscribe(this.forceUpdate); } _setHeaderHeight() { @@ -120,6 +123,10 @@ class RecentTransactions extends React.Component { return false; } + componentWillUnmount() { + ChainStore.unsubscribe(this.forceUpdate); + } + _onIncreaseLimit() { this.setState({ limit: this.state.limit + 30 From a24bf57f0ba8d24f09bd01b57957032313189636 Mon Sep 17 00:00:00 2001 From: Stefan Schiessl Date: Tue, 21 May 2019 14:00:29 +0200 Subject: [PATCH 11/12] add differentiation between active and owner add collapsed view Signed-off-by: Stefan Schiessl --- app/assets/locales/locale-en.json | 9 +- app/components/Account/Proposals.jsx | 1 + .../Blockchain/ProposedOperation.jsx | 10 +- app/components/Blockchain/Transaction.jsx | 1 + .../Blockchain/operations/AccountUpdate.jsx | 68 ++++-- app/components/Utility/TranslateWithLinks.jsx | 218 +++++++++++++++--- 6 files changed, 250 insertions(+), 57 deletions(-) diff --git a/app/assets/locales/locale-en.json b/app/assets/locales/locale-en.json index 8a0389f2d1..b37bd0c4c2 100644 --- a/app/assets/locales/locale-en.json +++ b/app/assets/locales/locale-en.json @@ -1545,16 +1545,21 @@ "asset_settle": "Request a settlement of {amount} for {account}", "asset_update": "Update the asset {asset} using the account {account}", "call_order_update": "Change {account} {debtSymbol} debt by {debt} and collateral by {collateral}", + "changes_to_active": "Changes to active", + "changes_to_owner": "Changes to owner", "committee_member_update_global_parameters": "Update committee global parameters by {account}", "delete": "Permanently reject", - "danger_operation": "Dangerous operation!", + "danger_operation": "Dangerous operation", + "set_threshold": "Set threshold to %(threshold)s", + "add": "Add", + "remove": "Remove", "expires": "Expires", "feed_producer": "Update the feed producers for the asset {asset} using the account {account}", "limit_order_buy": "Place an order to buy {amount} at {price} for {account}", "limit_order_create": "Place an order to buy %(buy_amount)s for %(sell_amount)s for %(account)s", "limit_order_sell": "Place an order to sell {amount} at {price} for {account}", "override_transfer": "Transfer {amount} from {from} to {to} by authority of {issuer}", - "public_key": "Key changes", + "permission_changes": "Permission changes", "proposals": "Proposals", "reject": "Reject", "status": "Status", diff --git a/app/components/Account/Proposals.jsx b/app/components/Account/Proposals.jsx index 3fdd578ab9..e03961d138 100644 --- a/app/components/Account/Proposals.jsx +++ b/app/components/Account/Proposals.jsx @@ -254,6 +254,7 @@ class Proposals extends Component { proposal={true} id={id} proposer={proposer} + collapsed={false} /> ); }) diff --git a/app/components/Blockchain/ProposedOperation.jsx b/app/components/Blockchain/ProposedOperation.jsx index b79f4082fa..3a39b19a8e 100644 --- a/app/components/Blockchain/ProposedOperation.jsx +++ b/app/components/Blockchain/ProposedOperation.jsx @@ -12,6 +12,7 @@ const {operations} = grapheneChainTypes; import PropTypes from "prop-types"; import opComponents from "./operations"; import TranslateWithLinks from "../Utility/TranslateWithLinks"; +import Operation from "../Account/RecentTransactions"; require("./operations.scss"); @@ -94,7 +95,8 @@ class ProposedOperation extends React.Component { hideDate: false, hideFee: false, hideOpLabel: false, - csvExportMode: false + csvExportMode: false, + collapsed: true }; static propTypes = { @@ -103,7 +105,8 @@ class ProposedOperation extends React.Component { block: PropTypes.number, hideDate: PropTypes.bool, hideFee: PropTypes.bool, - csvExportMode: PropTypes.bool + csvExportMode: PropTypes.bool, + collapsed: PropTypes.bool }; linkToAccount(name_or_id) { @@ -145,6 +148,7 @@ class ProposedOperation extends React.Component { const {label_color} = this.state; let line = null, column = null; + column = opComponents(ops[op[0]], this.props, { fromComponent: "proposed_operation", linkToAccount: this.linkToAccount, @@ -168,7 +172,7 @@ class ProposedOperation extends React.Component { /> :
-
{column}
+
{column}
); } diff --git a/app/components/Blockchain/Transaction.jsx b/app/components/Blockchain/Transaction.jsx index 4b4dbd8785..3e96be34f1 100644 --- a/app/components/Blockchain/Transaction.jsx +++ b/app/components/Blockchain/Transaction.jsx @@ -1723,6 +1723,7 @@ class Transaction extends React.Component { hideOpLabel={true} hideDate={true} proposal={true} + collapsed={true} /> ); }); diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx index e7bd68483a..0e2628b0d4 100644 --- a/app/components/Blockchain/operations/AccountUpdate.jsx +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -15,11 +15,11 @@ const getVotesName = item => { return id ? ChainStore.getAccountName(id) || id : item.get("worker") - ? item.get("name") - : null; + ? item.get("name") + : null; }; -export const AccountUpdate = ({op, fromComponent}) => { +export const AccountUpdate = ({op, fromComponent, collapsed}) => { const account = op[1].account; const votes = op[1].new_options ? op[1].new_options.votes : undefined; @@ -32,7 +32,11 @@ export const AccountUpdate = ({op, fromComponent}) => { let votesPlusNames = []; let votesMinusNames = []; - if (fromComponent === "proposed_operation") { + if (collapsed == undefined) { + collapsed = true; + } + + if (fromComponent === "proposed_operation" && !collapsed) { const _account = ChainStore.getAccount(account, false); const _votes = _account .get("options") @@ -64,31 +68,63 @@ export const AccountUpdate = ({op, fromComponent}) => { } if (owner) { - const _owner = _account - .get("active") + change.owner = {}; + const _owner_keys = _account + .get("owner") .get("key_auths") .map(a => a.get(0)) .toArray(); - change.keys = { - ...change.keys, - ...compareKeys(_owner, owner.key_auths.map(x => x[0])) - }; + change.owner.keys = compareKeys( + _owner_keys, + owner.key_auths.map(x => x[0]) + ); + const _owner_accounts = _account + .get("owner") + .get("account_auths") + .map(a => a.get(0)) + .toArray(); + change.owner.accounts = compareKeys( + _owner_accounts, + owner.account_auths.map(x => x[0]) + ); + if ( + _account.get("owner").get("weight_threshold") !== + owner.weight_threshold + ) { + change.owner.weight_threshold = owner.weight_threshold; + } } if (active) { - const _active = _account + change.active = {}; + const _active_keys = _account .get("active") .get("key_auths") .map(a => a.get(0)) .toArray(); - change.keys = { - ...change.keys, - ...compareKeys(_active, active.key_auths.map(x => x[0])) - }; + change.active.keys = compareKeys( + _active_keys, + active.key_auths.map(x => x[0]) + ); + const _active_accounts = _account + .get("active") + .get("account_auths") + .map(a => a.get(0)) + .toArray(); + change.active.accounts = compareKeys( + _active_accounts, + active.account_auths.map(x => x[0]) + ); + if ( + _account.get("active").get("weight_threshold") !== + active.weight_threshold + ) { + change.active.weight_threshold = owner.weight_threshold; + } } if (memo_key) { const _memo = _account.get("options").get("memo_key"); - change.keys = {...change.keys, ...compareKeys([_memo], [memo_key])}; + change.memo.keys = compareKeys([_memo], [memo_key]); } } diff --git a/app/components/Utility/TranslateWithLinks.jsx b/app/components/Utility/TranslateWithLinks.jsx index f74af7693d..23714fa7fb 100644 --- a/app/components/Utility/TranslateWithLinks.jsx +++ b/app/components/Utility/TranslateWithLinks.jsx @@ -140,49 +140,195 @@ export default class TranslateWithLinks extends React.Component { break; case "change": - const {votes, keys} = key.value; - if (key.value && (votes || keys)) { - value = ( - - {votes && - (votes.minus.length || - votes.plus.length) ? ( -
- - {votes && votes.minus.length ? ( + if (key.value && Object.keys(key.value).length > 0) { + const {votes, active, owner, memo} = key.value; + const voteDiv = votes && ( +
+ + {votes.minus.length ? ( +
- {votes.minus.join(", ")}
+ ) : null} + {votes.plus.length ? ( +
+ {votes.plus.join(", ")}
+ ) : null} +
+ ); + const warning = (active || owner || memo) && ( +
+ + {", "} + + {"!"} +
+ ); + const activeDiv = active && ( + + +
+ {active.keys.plus.length > 0 || + (active.accounts.plus.length > + 0 && (
- - {votes.minus.join(", ")} + {"- " + + counterpart.translate( + "proposal.add" + ) + + " "} + {active.keys.plus.join( + ", " + )}{" "} + {active.accounts.plus.map( + _tmp => ( + + {this.linkToAccount( + _tmp + )} + + ) + )}
- ) : null} - {votes && votes.plus.length ? ( + ))} + {active.keys.minus.length > 0 || + (active.accounts.minus.length > + 0 && (
- + {votes.plus.join(", ")} + {"- " + + counterpart.translate( + "proposal.remove" + ) + + " "} + {active.keys.minus.join( + ", " + )}{" "} + {active.accounts.minus.map( + _tmp => ( + + {this.linkToAccount( + _tmp + )} + + ) + )}
- ) : null} -
- ) : null} - {keys && - (keys.minus.length || keys.plus.length) ? ( -
- -
+ {keys.plus.join(", ")}
+ ))} + {active.weight_threshold && (
- {" "} - - {keys.minus.join(", ")} + {"- " + + counterpart.translate( + "proposal.set_threshold", + { + threshold: + active.weight_threshold + } + )}
- + )} +
+
+ ); + const ownerDiv = owner && ( + + +
+ {owner.keys.plus.length > 0 || + (owner.accounts.plus.length > 0 && ( +
+ {"- " + + counterpart.translate( + "proposal.add" + ) + + " "} + {owner.keys.plus.join(", ")}{" "} + {owner.accounts.plus.map( + _tmp => ( + + {this.linkToAccount( + _tmp + )} + + ) + )} +
+ ))} + {owner.keys.minus.length > 0 || + (owner.accounts.minus.length > + 0 && ( +
+ {"- " + + counterpart.translate( + "proposal.remove" + ) + + " "} + {owner.keys.minus.join( + ", " + )}{" "} + {owner.accounts.minus.map( + _tmp => ( + + {this.linkToAccount( + _tmp + )} + + ) + )} +
+ ))} + {owner.weight_threshold && ( +
+ {"- " + + counterpart.translate( + "proposal.set_threshold", + { + threshold: + owner.weight_threshold + } + )} +
+ )} +
+
+ ); + const memoDiv = memo && ( +
+ + {memo.keys.plus.length > 0 && ( +
+ {" "} + + {memo.keys.plus.join(", ")}
- ) : null} - + )} + {memo.keys.minus.length > 0 && ( +
+ {" "} + - {memo.keys.minus.join(", ")} +
+ )} +
+ ); + value = ( +
+ {warning} + {voteDiv} + {activeDiv} + {ownerDiv} + {memoDiv} +
); } else { value = ""; From 5376c5b612fce681c12b61dc5ac5fe239e34b625 Mon Sep 17 00:00:00 2001 From: Stefan Schiessl Date: Tue, 21 May 2019 14:35:47 +0200 Subject: [PATCH 12/12] fix visualization of votes Signed-off-by: Stefan Schiessl --- app/assets/locales/locale-en.json | 3 + app/components/Account/RecentTransactions.jsx | 6 -- .../Blockchain/operations/AccountUpdate.jsx | 47 ++++++++++++--- app/components/Utility/TranslateWithLinks.jsx | 58 ++++++++++++------- 4 files changed, 78 insertions(+), 36 deletions(-) diff --git a/app/assets/locales/locale-en.json b/app/assets/locales/locale-en.json index b5f6291876..ec50c8011d 100644 --- a/app/assets/locales/locale-en.json +++ b/app/assets/locales/locale-en.json @@ -1553,12 +1553,15 @@ "call_order_update": "Change {account} {debtSymbol} debt by {debt} and collateral by {collateral}", "changes_to_active": "Changes to active", "changes_to_owner": "Changes to owner", + "changes_to_memo": "Changes to memo", "committee_member_update_global_parameters": "Update committee global parameters by {account}", "delete": "Permanently reject", "danger_operation": "Dangerous operation", "set_threshold": "Set threshold to %(threshold)s", "add": "Add", "remove": "Remove", + "add_vote": "Add vote for", + "remove_vote": "Remove vote for", "expires": "Expires", "feed_producer": "Update the feed producers for the asset {asset} using the account {account}", "limit_order_buy": "Place an order to buy {amount} at {price} for {account}", diff --git a/app/components/Account/RecentTransactions.jsx b/app/components/Account/RecentTransactions.jsx index f47270100e..7f0b0a1979 100644 --- a/app/components/Account/RecentTransactions.jsx +++ b/app/components/Account/RecentTransactions.jsx @@ -83,7 +83,6 @@ class RecentTransactions extends React.Component { }; this.getDataSource = this.getDataSource.bind(this); - this.forceUpdate = this.forceUpdate.bind(this); this.useCustom = counterpart.translate( "account.export_modal.use_custom" ); @@ -105,7 +104,6 @@ class RecentTransactions extends React.Component { this._setHeaderHeight(); } - ChainStore.subscribe(this.forceUpdate); } esNodeChange(e) { @@ -194,10 +192,6 @@ class RecentTransactions extends React.Component { return false; } - componentWillUnmount() { - ChainStore.unsubscribe(this.forceUpdate); - } - _onIncreaseLimit() { this.setState({ limit: this.state.limit + 30 diff --git a/app/components/Blockchain/operations/AccountUpdate.jsx b/app/components/Blockchain/operations/AccountUpdate.jsx index 0e2628b0d4..75d3a47737 100644 --- a/app/components/Blockchain/operations/AccountUpdate.jsx +++ b/app/components/Blockchain/operations/AccountUpdate.jsx @@ -10,13 +10,35 @@ const compareKeys = (prev, next) => { }; const getVotesName = item => { - const id = - item.get("witness_account") || item.get("committee_member_account"); - return id - ? ChainStore.getAccountName(id) || id - : item.get("worker") - ? item.get("name") - : null; + if (item.id.startsWith("1.14")) { + // worker + let worker_account = ChainStore.getAccountName(item.worker_account); + return ( + "Worker " + + item.name + + (worker_account + ? " of " + worker_account + : " account " + item.worker_account) + ); + } else if (item.id.startsWith("1.6.")) { + let witness_account = ChainStore.getAccountName(item.witness_account); + return ( + "Witness " + + (witness_account + ? witness_account + : " account " + item.witness_account) + ); + } else { + let committee_member_account = ChainStore.getAccountName( + item.committee_member_account + ); + return ( + "Committee " + + (committee_member_account + ? committee_member_account + : " account " + item.committee_member_account) + ); + } }; export const AccountUpdate = ({op, fromComponent, collapsed}) => { @@ -53,13 +75,13 @@ export const AccountUpdate = ({op, fromComponent, collapsed}) => { if (votesPlusData && votesMinusData) { votesPlusData.forEach(item => { if (item) { - const name = getVotesName(item); + const name = getVotesName(item.toJS()); if (name) votesPlusNames.push(name); } }); votesMinusData.forEach(item => { if (item) { - const name = getVotesName(item); + const name = getVotesName(item.toJS()); if (name) votesMinusNames.push(name); } }); @@ -123,8 +145,15 @@ export const AccountUpdate = ({op, fromComponent, collapsed}) => { } if (memo_key) { + change.memo = {}; const _memo = _account.get("options").get("memo_key"); change.memo.keys = compareKeys([_memo], [memo_key]); + if ( + change.memo.keys.minus.length == 0 && + change.memo.keys.plus.length == 0 + ) { + change.memo = undefined; + } } } diff --git a/app/components/Utility/TranslateWithLinks.jsx b/app/components/Utility/TranslateWithLinks.jsx index 23714fa7fb..1f7835795b 100644 --- a/app/components/Utility/TranslateWithLinks.jsx +++ b/app/components/Utility/TranslateWithLinks.jsx @@ -146,10 +146,24 @@ export default class TranslateWithLinks extends React.Component {
{votes.minus.length ? ( -
- {votes.minus.join(", ")}
+
+ {"- " + + counterpart.translate( + "proposal.remove" + ) + + " "}{" "} + {votes.minus.join(", ")} +
) : null} {votes.plus.length ? ( -
+ {votes.plus.join(", ")}
+
+ {"- " + + counterpart.translate( + "proposal.add" + ) + + " "}{" "} + {votes.plus.join(", ")} +
) : null}
); @@ -297,25 +311,27 @@ export default class TranslateWithLinks extends React.Component {
); - const memoDiv = memo && ( -
- - {memo.keys.plus.length > 0 && ( -
- {" "} - + {memo.keys.plus.join(", ")} -
- )} - {memo.keys.minus.length > 0 && ( -
- {" "} - - {memo.keys.minus.join(", ")} -
- )} -
- ); + const memoDiv = memo && + (memo.keys.plus.length > 0 || + memo.keys.minus.length > 0) && ( +
+ + {memo.keys.plus.length > 0 && ( +
+ {" "} + + {memo.keys.plus.join(", ")} +
+ )} + {memo.keys.minus.length > 0 && ( +
+ {" "} + - {memo.keys.minus.join(", ")} +
+ )} +
+ ); value = (