txHash component: add maxConfirmations prop
This commit is contained in:
parent
3ef54f9172
commit
4931381e0e
@ -31,9 +31,14 @@ class TxHash extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
hash: PropTypes.string.isRequired,
|
hash: PropTypes.string.isRequired,
|
||||||
isTest: PropTypes.bool,
|
isTest: PropTypes.bool,
|
||||||
summary: PropTypes.bool
|
summary: PropTypes.bool,
|
||||||
|
maxConfirmations: PropTypes.number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
maxConfirmations: 10
|
||||||
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
blockNumber: new BigNumber(0),
|
blockNumber: new BigNumber(0),
|
||||||
transaction: null,
|
transaction: null,
|
||||||
@ -79,6 +84,7 @@ class TxHash extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderConfirmations () {
|
renderConfirmations () {
|
||||||
|
const { maxConfirmations } = this.props;
|
||||||
const { blockNumber, transaction } = this.state;
|
const { blockNumber, transaction } = this.state;
|
||||||
|
|
||||||
let txBlock = 'Pending';
|
let txBlock = 'Pending';
|
||||||
@ -89,14 +95,14 @@ class TxHash extends Component {
|
|||||||
const num = blockNumber.minus(transaction.blockNumber).plus(1);
|
const num = blockNumber.minus(transaction.blockNumber).plus(1);
|
||||||
txBlock = `#${transaction.blockNumber.toFormat(0)}`;
|
txBlock = `#${transaction.blockNumber.toFormat(0)}`;
|
||||||
confirmations = num.toFormat(0);
|
confirmations = num.toFormat(0);
|
||||||
value = num.gt(10) ? 10 : num.toNumber();
|
value = num.gt(maxConfirmations) ? maxConfirmations : num.toNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ styles.confirm }>
|
<div className={ styles.confirm }>
|
||||||
<LinearProgress
|
<LinearProgress
|
||||||
className={ styles.progressbar }
|
className={ styles.progressbar }
|
||||||
min={ 0 } max={ 10 } value={ value }
|
min={ 0 } max={ maxConfirmations } value={ value }
|
||||||
color='white'
|
color='white'
|
||||||
mode='determinate' />
|
mode='determinate' />
|
||||||
<div className={ styles.progressinfo }>
|
<div className={ styles.progressinfo }>
|
||||||
|
Loading…
Reference in New Issue
Block a user