From 4ba0b77572be37169d32b39b1a35106704acd8d6 Mon Sep 17 00:00:00 2001 From: HenryNguyen5 Date: Sun, 11 Mar 2018 21:44:05 -0400 Subject: [PATCH] Cleanup boolean logic, remove redundant code, make comparision elements more obvious --- .../SendButtonFactory/SendButtonFactory.tsx | 101 +++++++++--------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/common/components/SendButtonFactory/SendButtonFactory.tsx b/common/components/SendButtonFactory/SendButtonFactory.tsx index 62a76d6d..1130a6d5 100644 --- a/common/components/SendButtonFactory/SendButtonFactory.tsx +++ b/common/components/SendButtonFactory/SendButtonFactory.tsx @@ -1,7 +1,6 @@ import translate from 'translations'; import { getTransactionFields, makeTransaction } from 'libs/transaction'; import { OfflineBroadcast } from './OfflineBroadcast'; -import { SerializedTransaction } from 'components/renderCbs'; import { OnlineSend } from './OnlineSend'; import { addHexPrefix } from 'ethereumjs-util'; import { getWalletType, IWalletType } from 'selectors/wallet'; @@ -19,7 +18,7 @@ export interface CallbackProps { interface StateProps { walletType: IWalletType; - stateTransaction: AppState['transaction']['sign']['local']['signedTransaction']; + serializedTransaction: AppState['transaction']['sign']['local']['signedTransaction']; } interface OwnProps { @@ -29,73 +28,75 @@ interface OwnProps { withProps(props: CallbackProps): React.ReactElement | null; } -const getStringifiedTx = (serializedTransaction: string) => +const getStringifiedTx = (serializedTransaction: Buffer) => JSON.stringify(getTransactionFields(makeTransaction(serializedTransaction)), null, 2); type Props = StateProps & OwnProps; + class SendButtonFactoryClass extends Component { public render() { - const { onlyTransactionParameters, stateTransaction, toggleDisabled } = this.props; + const { + onlyTransactionParameters, + serializedTransaction, + toggleDisabled, + walletType + } = this.props; const columnSize = onlyTransactionParameters ? 12 : 6; + + /* Left and right transaction comparision boxes, only displayed when a serialized transaction + exists in state */ + + // shows the json representation of the transaction + const leftTxCompare = serializedTransaction && ( +
+ +