* Etherscan links (#4772) * Port tests * update address links * Signer accountlink isTest
This commit is contained in:
committed by
Arkadiy Paronyan
parent
02be8d869c
commit
260bcfd368
@@ -34,8 +34,8 @@ class TxHash extends Component {
|
||||
|
||||
static propTypes = {
|
||||
hash: PropTypes.string.isRequired,
|
||||
isTest: PropTypes.bool,
|
||||
maxConfirmations: PropTypes.number,
|
||||
netVersion: PropTypes.string.isRequired,
|
||||
summary: PropTypes.bool
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ class TxHash extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { hash, isTest, summary } = this.props;
|
||||
const { hash, netVersion, summary } = this.props;
|
||||
|
||||
const hashLink = (
|
||||
<a href={ txLink(hash, isTest) } target='_blank'>
|
||||
<a href={ txLink(hash, false, netVersion) } target='_blank'>
|
||||
<ShortenedHash data={ hash } />
|
||||
</a>
|
||||
);
|
||||
@@ -255,9 +255,11 @@ class TxHash extends Component {
|
||||
}
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const { isTest } = state.nodeStatus;
|
||||
const { netVersion } = state.nodeStatus;
|
||||
|
||||
return { isTest };
|
||||
return {
|
||||
netVersion
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -63,7 +63,9 @@ function createRedux () {
|
||||
subscribe: sinon.stub(),
|
||||
getState: () => {
|
||||
return {
|
||||
nodeStatus: { isTest: true }
|
||||
nodeStatus: {
|
||||
netVersion: '42'
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import moment from 'moment';
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { txLink, addressLink } from '~/3rdparty/etherscan/links';
|
||||
|
||||
@@ -25,7 +26,7 @@ import MethodDecoding from '../../MethodDecoding';
|
||||
|
||||
import styles from '../txList.css';
|
||||
|
||||
export default class TxRow extends Component {
|
||||
class TxRow extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object.isRequired
|
||||
};
|
||||
@@ -33,7 +34,7 @@ export default class TxRow extends Component {
|
||||
static propTypes = {
|
||||
tx: PropTypes.object.isRequired,
|
||||
address: PropTypes.string.isRequired,
|
||||
isTest: PropTypes.bool.isRequired,
|
||||
netVersion: PropTypes.string.isRequired,
|
||||
|
||||
block: PropTypes.object,
|
||||
historic: PropTypes.bool,
|
||||
@@ -45,7 +46,7 @@ export default class TxRow extends Component {
|
||||
};
|
||||
|
||||
render () {
|
||||
const { tx, address, isTest, historic, className } = this.props;
|
||||
const { address, className, historic, netVersion, tx } = this.props;
|
||||
|
||||
return (
|
||||
<tr className={ className || '' }>
|
||||
@@ -57,8 +58,9 @@ export default class TxRow extends Component {
|
||||
<div>
|
||||
<a
|
||||
className={ styles.link }
|
||||
href={ txLink(tx.hash, isTest) }
|
||||
target='_blank'>
|
||||
href={ txLink(tx.hash, false, netVersion) }
|
||||
target='_blank'
|
||||
>
|
||||
{ `${tx.hash.substr(2, 6)}...${tx.hash.slice(-6)}` }
|
||||
</a>
|
||||
</div>
|
||||
@@ -75,13 +77,13 @@ export default class TxRow extends Component {
|
||||
}
|
||||
|
||||
renderAddress (address) {
|
||||
const { isTest } = this.props;
|
||||
const { netVersion } = this.props;
|
||||
|
||||
let esLink = null;
|
||||
if (address) {
|
||||
esLink = (
|
||||
<a
|
||||
href={ addressLink(address, isTest) }
|
||||
href={ addressLink(address, false, netVersion) }
|
||||
target='_blank'
|
||||
className={ styles.link }>
|
||||
<IdentityName address={ address } shorten />
|
||||
@@ -131,3 +133,16 @@ export default class TxRow extends Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const { netVersion } = state.nodeStatus;
|
||||
|
||||
return {
|
||||
netVersion
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
)(TxRow);
|
||||
|
||||
@@ -25,9 +25,27 @@ import TxRow from './txRow';
|
||||
|
||||
const api = new Api({ execute: sinon.stub() });
|
||||
|
||||
const STORE = {
|
||||
dispatch: sinon.stub(),
|
||||
subscribe: sinon.stub(),
|
||||
getState: () => {
|
||||
return {
|
||||
nodeStatus: {
|
||||
netVersion: '42'
|
||||
},
|
||||
personal: {
|
||||
accounts: {
|
||||
'0x123': {}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function render (props) {
|
||||
return shallow(
|
||||
<TxRow
|
||||
store={ STORE }
|
||||
{ ...props } />,
|
||||
{ context: { api } }
|
||||
);
|
||||
@@ -45,7 +63,7 @@ describe('ui/TxList/TxRow', () => {
|
||||
value: new BigNumber(1)
|
||||
};
|
||||
|
||||
expect(render({ address: '0x123', block, isTest: true, tx })).to.be.ok;
|
||||
expect(render({ address: '0x123', block, netVersion: '42', tx })).to.be.ok;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ class TxList extends Component {
|
||||
PropTypes.array,
|
||||
PropTypes.object
|
||||
]).isRequired,
|
||||
isTest: PropTypes.bool.isRequired
|
||||
netVersion: PropTypes.string.isRequired
|
||||
}
|
||||
|
||||
store = new Store(this.context.api);
|
||||
@@ -63,7 +63,7 @@ class TxList extends Component {
|
||||
}
|
||||
|
||||
renderRows () {
|
||||
const { address, isTest } = this.props;
|
||||
const { address, netVersion } = this.props;
|
||||
|
||||
return this.store.sortedHashes.map((txhash) => {
|
||||
const tx = this.store.transactions[txhash];
|
||||
@@ -76,7 +76,7 @@ class TxList extends Component {
|
||||
tx={ tx }
|
||||
block={ block }
|
||||
address={ address }
|
||||
isTest={ isTest }
|
||||
netVersion={ netVersion }
|
||||
/>
|
||||
);
|
||||
});
|
||||
@@ -84,10 +84,10 @@ class TxList extends Component {
|
||||
}
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const { isTest } = state.nodeStatus;
|
||||
const { netVersion } = state.nodeStatus;
|
||||
|
||||
return {
|
||||
isTest
|
||||
netVersion
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const STORE = {
|
||||
getState: () => {
|
||||
return {
|
||||
nodeStatus: {
|
||||
isTest: true
|
||||
netVersion: '42'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user