2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-11-29 13:50:09 +01:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-01-11 17:02:53 +01:00
|
|
|
import { observer } from 'mobx-react';
|
2016-11-29 13:50:09 +01:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import Store from './store';
|
2016-12-09 10:55:46 +01:00
|
|
|
import TxRow from './TxRow';
|
2016-11-29 13:50:09 +01:00
|
|
|
|
|
|
|
import styles from './txList.css';
|
|
|
|
|
2016-12-02 15:21:01 +01:00
|
|
|
@observer
|
|
|
|
class TxList extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
api: PropTypes.object.isRequired
|
2017-03-07 20:19:55 +01:00
|
|
|
};
|
2016-12-02 15:21:01 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
address: PropTypes.string.isRequired,
|
|
|
|
hashes: PropTypes.oneOfType([
|
|
|
|
PropTypes.array,
|
|
|
|
PropTypes.object
|
|
|
|
]).isRequired,
|
2017-04-25 10:08:09 +02:00
|
|
|
blockNumber: PropTypes.object,
|
|
|
|
netVersion: PropTypes.string.isRequired,
|
|
|
|
onNewError: PropTypes.func
|
2017-03-07 20:19:55 +01:00
|
|
|
};
|
2016-12-02 15:21:01 +01:00
|
|
|
|
|
|
|
componentWillMount () {
|
2017-04-25 10:08:09 +02:00
|
|
|
this.store = new Store(this.context.api, this.props.onNewError, this.props.hashes);
|
2016-12-02 15:21:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps (newProps) {
|
|
|
|
this.store.loadTransactions(newProps.hashes);
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<table className={ styles.transactions }>
|
|
|
|
<tbody>
|
|
|
|
{ this.renderRows() }
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderRows () {
|
2017-04-25 10:08:09 +02:00
|
|
|
const { address, netVersion, blockNumber } = this.props;
|
2017-06-23 10:32:19 +02:00
|
|
|
const { editTransaction, cancelTransaction, killTransaction } = this.store;
|
2016-12-02 15:21:01 +01:00
|
|
|
|
|
|
|
return this.store.sortedHashes.map((txhash) => {
|
|
|
|
const tx = this.store.transactions[txhash];
|
2017-04-25 10:08:09 +02:00
|
|
|
const txBlockNumber = tx.blockNumber.toNumber();
|
|
|
|
const block = this.store.blocks[txBlockNumber];
|
2016-12-02 15:21:01 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TxRow
|
|
|
|
key={ tx.hash }
|
|
|
|
tx={ tx }
|
|
|
|
block={ block }
|
2017-04-25 10:08:09 +02:00
|
|
|
blockNumber={ blockNumber }
|
2016-12-02 15:21:01 +01:00
|
|
|
address={ address }
|
2017-03-06 08:54:59 +01:00
|
|
|
netVersion={ netVersion }
|
2017-04-25 10:08:09 +02:00
|
|
|
editTransaction={ editTransaction }
|
|
|
|
cancelTransaction={ cancelTransaction }
|
2017-06-23 10:32:19 +02:00
|
|
|
killTransaction={ killTransaction }
|
2016-12-02 15:21:01 +01:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-29 13:50:09 +01:00
|
|
|
function mapStateToProps (state) {
|
2017-03-06 08:54:59 +01:00
|
|
|
const { netVersion } = state.nodeStatus;
|
2016-11-29 13:50:09 +01:00
|
|
|
|
|
|
|
return {
|
2017-03-06 08:54:59 +01:00
|
|
|
netVersion
|
2016-11-29 13:50:09 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
2017-01-11 17:02:53 +01:00
|
|
|
null
|
2016-11-29 13:50:09 +01:00
|
|
|
)(TxList);
|