diff --git a/app/components/Contacts/ClosingContact.js b/app/components/Contacts/ClosingContact.js index 15a18632..9da04523 100644 --- a/app/components/Contacts/ClosingContact.js +++ b/app/components/Contacts/ClosingContact.js @@ -1,8 +1,7 @@ -import { shell } from 'electron' import React from 'react' import PropTypes from 'prop-types' import { FaCircle } from 'react-icons/lib/fa' -import { btc } from 'utils' +import { btc, blockExplorer } from 'utils' import styles from './Contact.scss' const ClosingContact = ({ channel }) => ( @@ -12,7 +11,7 @@ const ClosingContact = ({ channel }) => ( Removing - shell.openExternal(`${'https://testnet.smartbit.com.au'}/tx/${channel.closing_txid}`)}> + blockExplorer.showChannelClosing(channel)}> (Details) diff --git a/app/components/Contacts/PendingContact.js b/app/components/Contacts/PendingContact.js index 9191ab49..d56bfaec 100644 --- a/app/components/Contacts/PendingContact.js +++ b/app/components/Contacts/PendingContact.js @@ -1,8 +1,7 @@ -import { shell } from 'electron' import React from 'react' import PropTypes from 'prop-types' import { FaCircle } from 'react-icons/lib/fa' -import { btc } from 'utils' +import { btc, blockExplorer } from 'utils' import styles from './Contact.scss' const PendingContact = ({ channel }) => ( @@ -12,7 +11,7 @@ const PendingContact = ({ channel }) => ( Pending - shell.openExternal(`${'https://testnet.smartbit.com.au'}/tx/${channel.channel.channel_point.split(':')[0]}`)}> + blockExplorer.showChannelPoint(channel)}> (Details) diff --git a/app/components/ModalRoot/SuccessfulSendCoins.js b/app/components/ModalRoot/SuccessfulSendCoins.js index c0b101fe..07df8322 100644 --- a/app/components/ModalRoot/SuccessfulSendCoins.js +++ b/app/components/ModalRoot/SuccessfulSendCoins.js @@ -1,8 +1,7 @@ -import { shell } from 'electron' import React from 'react' import PropTypes from 'prop-types' import AnimatedCheckmark from 'components/AnimatedCheckmark' -import { btc } from 'utils' +import { btc, blockExplorer } from 'utils' import styles from './SuccessfulSendCoins.scss' const SuccessfulSendCoins = ({ @@ -15,7 +14,7 @@ const SuccessfulSendCoins = ({

You  - shell.openExternal(`https://testnet.smartbit.com.au/tx/${txid}`)}>sent  + blockExplorer.showTransaction(txid)}>sent  {calculatedAmount} {currency.toUpperCase()}  to  {addr} diff --git a/app/components/Network/ChannelsList.js b/app/components/Network/ChannelsList.js index 3c1c55dc..2cf78594 100644 --- a/app/components/Network/ChannelsList.js +++ b/app/components/Network/ChannelsList.js @@ -1,7 +1,6 @@ -import { shell } from 'electron' import React from 'react' import PropTypes from 'prop-types' -import { btc } from 'utils' +import { btc, blockExplorer } from 'utils' import styles from './ChannelsList.scss' const ChannelsList = ({ channels, updateSelectedChannels, selectedChannelIds }) => ( @@ -13,7 +12,7 @@ const ChannelsList = ({ channels, updateSelectedChannels, selectedChannelIds })

Capacity: {btc.satoshisToBtc(channel.capacity)}

- shell.openExternal(`https://testnet.smartbit.com.au/tx/${channel.channel_point.split(':')[0]}`)}>Channel Point + blockExplorer.showChannelPoint({ channel })}>Channel Point
diff --git a/app/reducers/info.js b/app/reducers/info.js index f86641d3..69f16f33 100644 --- a/app/reducers/info.js +++ b/app/reducers/info.js @@ -1,5 +1,6 @@ import { createSelector } from 'reselect' import { ipcRenderer } from 'electron' +import { blockExplorer } from 'utils' // ------------------------------------ // Constants @@ -57,7 +58,7 @@ infoSelectors.isTestnet = createSelector( infoSelectors.explorerLinkBase = createSelector( infoSelectors.isTestnet, - isTestnet => (isTestnet ? 'https://testnet.smartbit.com.au' : 'https://smartbit.com.au') + isTestnet => (isTestnet ? blockExplorer.testnetUrl : blockExplorer.mainnetUrl) ) export { infoSelectors } diff --git a/app/routes/activity/components/components/Modal/Transaction/Transaction.js b/app/routes/activity/components/components/Modal/Transaction/Transaction.js index 33f2dc0b..b015281a 100644 --- a/app/routes/activity/components/components/Modal/Transaction/Transaction.js +++ b/app/routes/activity/components/components/Modal/Transaction/Transaction.js @@ -1,11 +1,10 @@ -import { shell } from 'electron' import React from 'react' import PropTypes from 'prop-types' import Moment from 'react-moment' import 'moment-timezone' -import { btc } from 'utils' +import { btc, blockExplorer } from 'utils' import styles from './Transaction.scss' @@ -34,7 +33,7 @@ const Transaction = ({ transaction, ticker, currentTicker }) => ( BTC

-

shell.openExternal(`https://testnet.smartbit.com.au/tx/${transaction.tx_hash}`)}>{transaction.tx_hash}

+

blockExplorer.showTransaction(transaction.tx_hash)}>{transaction.tx_hash}

Confirmations
diff --git a/app/utils/blockExplorer.js b/app/utils/blockExplorer.js new file mode 100644 index 00000000..6b6aaa51 --- /dev/null +++ b/app/utils/blockExplorer.js @@ -0,0 +1,21 @@ +import { shell } from 'electron' + +const testnetUrl = 'https://testnet.smartbit.com.au' +const mainnetUrl = 'https://smartbit.com.au' + +const showTransaction = txid => + shell.openExternal(`${testnetUrl}/tx/${txid}`) + +const showChannelClosing = channel => + showTransaction(channel.closing_txid) + +const showChannelPoint = channel => + showTransaction(channel.channel.channel_point.split(':')[0]) + +export default { + testnetUrl, + mainnetUrl, + showTransaction, + showChannelClosing, + showChannelPoint +} diff --git a/app/utils/index.js b/app/utils/index.js index 3d162c0f..45dcde6d 100644 --- a/app/utils/index.js +++ b/app/utils/index.js @@ -1,9 +1,11 @@ import btc from './btc' import usd from './usd' import bech32 from './bech32' +import blockExplorer from './blockExplorer' export default { btc, usd, - bech32 + bech32, + blockExplorer }