Etherscan links based on netVersion identifier (#4772)
* Use netVersion to determine external links * Update additional isTest references
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -69,7 +69,9 @@ function createRedux () {
|
||||
subscribe: sinon.stub(),
|
||||
getState: () => {
|
||||
return {
|
||||
nodeStatus: { isTest: true }
|
||||
nodeStatus: {
|
||||
netVersion: '42'
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ class TxRow extends Component {
|
||||
static propTypes = {
|
||||
accountAddresses: PropTypes.array.isRequired,
|
||||
address: PropTypes.string.isRequired,
|
||||
isTest: PropTypes.bool.isRequired,
|
||||
netVersion: PropTypes.string.isRequired,
|
||||
tx: PropTypes.object.isRequired,
|
||||
|
||||
block: PropTypes.object,
|
||||
@@ -48,7 +48,7 @@ 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 || '' }>
|
||||
@@ -60,7 +60,7 @@ class TxRow extends Component {
|
||||
<div>
|
||||
<a
|
||||
className={ styles.link }
|
||||
href={ txLink(tx.hash, isTest) }
|
||||
href={ txLink(tx.hash, false, netVersion) }
|
||||
target='_blank'
|
||||
>
|
||||
{ `${tx.hash.substr(2, 6)}...${tx.hash.slice(-6)}` }
|
||||
@@ -156,8 +156,13 @@ function mapStateToProps (initState) {
|
||||
const { accounts } = initState.personal;
|
||||
const accountAddresses = Object.keys(accounts);
|
||||
|
||||
return () => {
|
||||
return { accountAddresses };
|
||||
return (state) => {
|
||||
const { netVersion } = state.nodeStatus;
|
||||
|
||||
return {
|
||||
accountAddresses,
|
||||
netVersion
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -165,4 +170,3 @@ export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
)(TxRow);
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ const STORE = {
|
||||
subscribe: sinon.stub(),
|
||||
getState: () => {
|
||||
return {
|
||||
nodeStatus: {
|
||||
netVersion: '42'
|
||||
},
|
||||
personal: {
|
||||
accounts: {
|
||||
'0x123': {}
|
||||
@@ -61,7 +64,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;
|
||||
});
|
||||
|
||||
it('renders an account link', () => {
|
||||
@@ -75,7 +78,7 @@ describe('ui/TxList/TxRow', () => {
|
||||
value: new BigNumber(1)
|
||||
};
|
||||
|
||||
const element = render({ address: '0x123', block, isTest: true, tx });
|
||||
const element = render({ address: '0x123', block, netVersion: '42', tx });
|
||||
|
||||
expect(element.find('Link').prop('to')).to.equal('/accounts/0x123');
|
||||
});
|
||||
@@ -91,7 +94,7 @@ describe('ui/TxList/TxRow', () => {
|
||||
value: new BigNumber(1)
|
||||
};
|
||||
|
||||
const element = render({ address: '0x123', block, isTest: true, tx });
|
||||
const element = render({ address: '0x123', block, netVersion: '42', tx });
|
||||
|
||||
expect(element.find('Link').prop('to')).to.equal('/addresses/0x456');
|
||||
});
|
||||
|
||||
@@ -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