2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-12-06 09:37:59 +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-07-17 18:37:33 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-03-02 12:24:54 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2016-12-06 09:37:59 +01:00
|
|
|
|
2017-04-21 11:40:22 +02:00
|
|
|
import { bytesToHex } from '@parity/api/util/format';
|
2017-05-12 12:06:16 +02:00
|
|
|
import { Container } from '@parity/ui';
|
|
|
|
import TxRow from '@parity/ui/TxList/TxRow';
|
|
|
|
import txListStyles from '@parity/ui/TxList/txList.css';
|
2016-12-06 09:37:59 +01:00
|
|
|
|
|
|
|
export default class WalletTransactions extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
address: PropTypes.string.isRequired,
|
2017-03-06 08:54:59 +01:00
|
|
|
netVersion: PropTypes.string.isRequired,
|
2016-12-06 09:37:59 +01:00
|
|
|
transactions: PropTypes.array
|
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
transactions: []
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<div>
|
2017-03-02 12:24:54 +01:00
|
|
|
<Container
|
|
|
|
title={
|
|
|
|
<FormattedMessage
|
|
|
|
id='wallet.transactions.title'
|
|
|
|
defaultMessage='Transactions'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
2016-12-06 09:37:59 +01:00
|
|
|
{ this.renderTransactions() }
|
|
|
|
</Container>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
renderTransactions () {
|
2017-03-06 08:54:59 +01:00
|
|
|
const { address, netVersion, transactions } = this.props;
|
2016-12-06 09:37:59 +01:00
|
|
|
|
|
|
|
if (!transactions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transactions.length === 0) {
|
|
|
|
return (
|
|
|
|
<div>
|
2017-03-02 12:24:54 +01:00
|
|
|
<p>
|
|
|
|
<FormattedMessage
|
|
|
|
id='wallet.transactions.none'
|
|
|
|
defaultMessage='No transactions has been sent.'
|
|
|
|
/>
|
|
|
|
</p>
|
2016-12-06 09:37:59 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-12-30 12:28:12 +01:00
|
|
|
const txRows = transactions.slice(0, 15).map((transaction, index) => {
|
2017-03-07 20:19:55 +01:00
|
|
|
const { transactionHash, data } = transaction;
|
2016-12-06 09:37:59 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TxRow
|
2017-03-02 12:24:54 +01:00
|
|
|
address={ address }
|
2017-03-06 08:54:59 +01:00
|
|
|
netVersion={ netVersion }
|
2016-12-30 12:28:12 +01:00
|
|
|
key={ `${transactionHash}_${index}` }
|
2016-12-06 09:37:59 +01:00
|
|
|
tx={ {
|
|
|
|
hash: transactionHash,
|
|
|
|
input: data && bytesToHex(data) || '',
|
2017-03-07 20:19:55 +01:00
|
|
|
...transaction
|
2016-12-06 09:37:59 +01:00
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<table className={ txListStyles.transactions }>
|
|
|
|
<tbody>
|
|
|
|
{ txRows }
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|