Pass MethodDecoding as to/destination view

This commit is contained in:
Jaco Greeff 2016-11-29 16:37:25 +01:00
parent 6a69e22b28
commit efd4e6f96a
7 changed files with 56 additions and 102 deletions

View File

@ -19,6 +19,6 @@ $pendingHeight: 190px;
$finishedHeight: 120px; $finishedHeight: 120px;
$embedWidth: 920px; $embedWidth: 920px;
$statusWidth: 260px; $statusWidth: 270px;
$accountPadding: 75px; $accountPadding: 75px;

View File

@ -74,12 +74,7 @@ export default class RequestPending extends Component {
onReject={ onReject } onReject={ onReject }
isSending={ isSending } isSending={ isSending }
id={ id } id={ id }
gasPrice={ transaction.gasPrice } transaction={ transaction }
gas={ transaction.gas }
data={ transaction.data }
from={ transaction.from }
to={ transaction.to }
value={ transaction.value }
date={ date } date={ date }
isTest={ isTest } isTest={ isTest }
store={ store } store={ store }

View File

@ -30,27 +30,26 @@
text-align: center; text-align: center;
} }
.from, .to { .from {
width: 50%; width: 40%;
vertical-align: top;
img {
display: inline-block;
width: 50px;
height: 50px;
margin: 5px;
}
span {
display: block;
}
} }
.from .account { .method {
padding-right: $accountPadding; width: 60%;
} vertical-align: top;
line-height: 1em;
.to .account {
padding-left: $accountPadding;
}
.from img, .to img {
display: inline-block;
width: 50px;
height: 50px;
margin: 5px;
}
.from span, .to span {
display: block;
} }
.tx { .tx {

View File

@ -16,9 +16,10 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import ContractIcon from 'material-ui/svg-icons/action/code';
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { MethodDecoding } from '../../../../ui';
import * as tUtil from '../util/transaction'; import * as tUtil from '../util/transaction';
import Account from '../Account'; import Account from '../Account';
import styles from './TransactionMainDetails.css'; import styles from './TransactionMainDetails.css';
@ -32,6 +33,7 @@ export default class TransactionMainDetails extends Component {
totalValue: PropTypes.object.isRequired, // wei BigNumber totalValue: PropTypes.object.isRequired, // wei BigNumber
isTest: PropTypes.bool.isRequired, isTest: PropTypes.bool.isRequired,
to: PropTypes.string, // undefined if it's a contract to: PropTypes.string, // undefined if it's a contract
transaction: PropTypes.object.isRequired,
toBalance: PropTypes.object, // eth BigNumber - undefined if it's a contract or until it's fetched toBalance: PropTypes.object, // eth BigNumber - undefined if it's a contract or until it's fetched
children: PropTypes.node children: PropTypes.node
}; };
@ -59,15 +61,7 @@ export default class TransactionMainDetails extends Component {
} }
render () { render () {
const { to } = this.props; const { children, from, fromBalance, transaction, isTest } = this.props;
return to
? this.renderTransfer()
: this.renderContract();
}
renderTransfer () {
const { children, from, fromBalance, to, toBalance, isTest } = this.props;
return ( return (
<div className={ styles.transaction }> <div className={ styles.transaction }>
@ -79,48 +73,11 @@ export default class TransactionMainDetails extends Component {
isTest={ isTest } /> isTest={ isTest } />
</div> </div>
</div> </div>
<div className={ styles.tx }> <div className={ styles.method }>
{ this.renderValue() } <MethodDecoding
<div>&rArr;</div> address={ from }
{ this.renderTotalValue() } transaction={ transaction }
</div> historic={ false } />
<div className={ styles.to }>
<div className={ styles.account }>
<Account
address={ to }
balance={ toBalance }
isTest={ isTest } />
</div>
</div>
{ children }
</div>
);
}
renderContract () {
const { children, from, fromBalance, isTest } = this.props;
return (
<div className={ styles.transaction }>
<div className={ styles.from }>
<div className={ styles.account }>
<Account
address={ from }
balance={ fromBalance }
isTest={ isTest } />
</div>
</div>
<div className={ styles.tx }>
{ this.renderValue() }
<div>&rArr;</div>
{ this.renderTotalValue() }
</div>
<div className={ styles.to }>
<div className={ styles.account }>
<ContractIcon className={ styles.contractIcon } />
<br />
Contract
</div>
</div> </div>
{ children } { children }
</div> </div>

View File

@ -19,9 +19,13 @@
.container { .container {
display: flex; display: flex;
padding: 1.5em 0 1em; padding: 1em 0 1em;
& > * { & > * {
vertical-align: middle; vertical-align: middle;
} }
} }
.container+.container {
padding-top: 2em;
}

View File

@ -19,7 +19,6 @@ import { observer } from 'mobx-react';
import TransactionMainDetails from '../TransactionMainDetails'; import TransactionMainDetails from '../TransactionMainDetails';
import TransactionPendingForm from '../TransactionPendingForm'; import TransactionPendingForm from '../TransactionPendingForm';
import TransactionSecondaryDetails from '../TransactionSecondaryDetails';
import styles from './TransactionPending.css'; import styles from './TransactionPending.css';
@ -29,13 +28,15 @@ import * as tUtil from '../util/transaction';
export default class TransactionPending extends Component { export default class TransactionPending extends Component {
static propTypes = { static propTypes = {
id: PropTypes.object.isRequired, id: PropTypes.object.isRequired,
from: PropTypes.string.isRequired, transaction: PropTypes.shape({
value: PropTypes.object.isRequired, // wei hex from: PropTypes.string.isRequired,
gasPrice: PropTypes.object.isRequired, // wei hex value: PropTypes.object.isRequired, // wei hex
gas: PropTypes.object.isRequired, // hex gasPrice: PropTypes.object.isRequired, // wei hex
gas: PropTypes.object.isRequired, // hex
data: PropTypes.string, // hex
to: PropTypes.string // undefined if it's a contract
}).isRequired,
date: PropTypes.instanceOf(Date).isRequired, date: PropTypes.instanceOf(Date).isRequired,
to: PropTypes.string, // undefined if it's a contract
data: PropTypes.string, // hex
nonce: PropTypes.number, nonce: PropTypes.number,
onConfirm: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired,
onReject: PropTypes.func.isRequired, onReject: PropTypes.func.isRequired,
@ -50,7 +51,8 @@ export default class TransactionPending extends Component {
}; };
componentWillMount () { componentWillMount () {
const { gas, gasPrice, value, from, to, store } = this.props; const { transaction, store } = this.props;
const { gas, gasPrice, value, from, to } = transaction;
const fee = tUtil.getFee(gas, gasPrice); // BigNumber object const fee = tUtil.getFee(gas, gasPrice); // BigNumber object
const totalValue = tUtil.getTotalValue(fee, value); const totalValue = tUtil.getTotalValue(fee, value);
@ -62,8 +64,9 @@ export default class TransactionPending extends Component {
} }
render () { render () {
const { className, id, date, data, from, to, store } = this.props; const { className, id, transaction, store } = this.props;
const { totalValue, gasPriceEthmDisplay, gasToDisplay } = this.state; const { from, to, value } = transaction;
const { totalValue } = this.state;
const fromBalance = store.balances[from]; const fromBalance = store.balances[from];
const toBalance = store.balances[to]; const toBalance = store.balances[to];
@ -71,20 +74,15 @@ export default class TransactionPending extends Component {
return ( return (
<div className={ `${styles.container} ${className || ''}` }> <div className={ `${styles.container} ${className || ''}` }>
<TransactionMainDetails <TransactionMainDetails
{ ...this.props } id={ id }
{ ...this.state } value={ value }
from={ from }
fromBalance={ fromBalance } fromBalance={ fromBalance }
to={ to }
toBalance={ toBalance } toBalance={ toBalance }
className={ styles.transactionDetails } className={ styles.transactionDetails }
totalValue={ totalValue }> transaction={ transaction }
<TransactionSecondaryDetails totalValue={ totalValue } />
id={ id }
date={ date }
data={ data }
gasPriceEthmDisplay={ gasPriceEthmDisplay }
gasToDisplay={ gasToDisplay }
/>
</TransactionMainDetails>
<TransactionPendingForm <TransactionPendingForm
address={ from } address={ from }
isSending={ this.props.isSending } isSending={ this.props.isSending }
@ -96,7 +94,8 @@ export default class TransactionPending extends Component {
} }
onConfirm = data => { onConfirm = data => {
const { id, gasPrice } = this.props; const { id, transaction } = this.props;
const { gasPrice } = transaction;
const { password, wallet } = data; const { password, wallet } = data;
this.props.onConfirm({ id, password, wallet, gasPrice }); this.props.onConfirm({ id, password, wallet, gasPrice });

View File

@ -19,7 +19,7 @@
.container { .container {
box-sizing: border-box; box-sizing: border-box;
padding: 1em 1em 0 1em; padding: 1em 0 0 2em;
flex: 0 0 $statusWidth; flex: 0 0 $statusWidth;
} }