Merge pull request #111 from Permissionless-Software-Foundation/dh-bcha-explorer

feat(explorer): Link to correct block explorer
This commit is contained in:
Chris Troutner
2020-11-25 06:55:00 -08:00
committed by GitHub
+25 -2
View File
@@ -23,7 +23,8 @@ class Send extends React.Component {
showScan: false, showScan: false,
inFetch: false, inFetch: false,
sendCurrency: 'USD', sendCurrency: 'USD',
sendMax: false sendMax: false,
explorerURL: ''
} }
_this.BchWallet = BchWallet _this.BchWallet = BchWallet
} }
@@ -118,7 +119,7 @@ class Send extends React.Component {
<a <a
target='_blank' target='_blank'
rel='noopener noreferrer' rel='noopener noreferrer'
href={`https://explorer.bitcoin.com/bch/tx/${_this.state.txId}`} href={`${_this.state.explorerURL}/${_this.state.txId}`}
> >
Transaction ID: {_this.state.txId} Transaction ID: {_this.state.txId}
</a> </a>
@@ -139,6 +140,28 @@ class Send extends React.Component {
) )
} }
componentDidMount () {
_this.defineExplorer()
}
// Define the explorer to use
// depending on the selected chain
defineExplorer () {
const bchWalletLib = _this.props.bchWallet
const bchjs = bchWalletLib.bchjs
let explorerURL
if (bchjs.restURL.includes('abc.fullstack')) {
explorerURL = 'https://explorer.bitcoinabc.org/tx'
} else {
explorerURL = 'https://explorer.bitcoin.com/bch/tx'
}
_this.setState({
explorerURL
})
}
handleChangeCurrency () { handleChangeCurrency () {
if (_this.state.sendCurrency === 'USD') { if (_this.state.sendCurrency === 'USD') {
_this.setState({ _this.setState({