Browse Source

Merge pull request #408 from LN-Zap/fix/dynamic-explorer-links

Fix/dynamic explorer links
renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
5cb6863bcb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/components/Activity/ActivityModal.js
  2. 9
      app/components/Activity/TransactionModal.js
  3. 8
      app/components/Contacts/Network.js
  4. 6
      app/components/ModalRoot/ModalRoot.js
  5. 7
      app/components/ModalRoot/SuccessfulSendCoins.js
  6. 6
      app/components/Wallet/Wallet.js
  7. 1
      app/routes/activity/containers/ActivityContainer.js
  8. 3
      app/routes/app/components/App.js
  9. 2
      app/routes/app/containers/AppContainer.js
  10. 8
      app/utils/blockExplorer.js

4
app/components/Activity/ActivityModal.js

@ -14,6 +14,7 @@ const ActivityModal = ({
modalProps,
ticker,
currentTicker,
isTestnet,
hideActivityModal,
toggleCurrencyProps
@ -36,6 +37,7 @@ const ActivityModal = ({
</div>
<SpecificModal
{...modalProps}
isTestnet={isTestnet}
ticker={ticker}
currentTicker={currentTicker}
toggleCurrencyProps={toggleCurrencyProps}
@ -49,6 +51,8 @@ ActivityModal.propTypes = {
currentTicker: PropTypes.object.isRequired,
toggleCurrencyProps: PropTypes.object.isRequired,
isTestnet: PropTypes.bool.isRequired,
modalType: PropTypes.string,
modalProps: PropTypes.object.isRequired,
hideActivityModal: PropTypes.func.isRequired

9
app/components/Activity/TransactionModal.js

@ -19,6 +19,7 @@ const TransactionModal = ({
transaction,
ticker,
currentTicker,
isTestnet,
toggleCurrencyProps: {
setActivityModalCurrencyFilters,
@ -37,7 +38,7 @@ const TransactionModal = ({
<section className={styles.details}>
<div>
<Isvg src={link} />
<span className={styles.link} onClick={() => blockExplorer.showTransaction(transaction.tx_hash)}>On-Chain</span>
<span className={styles.link} onClick={() => blockExplorer.showTransaction(isTestnet, transaction.tx_hash)}>On-Chain</span>
</div>
<div>
<Value value={transaction.total_fees} currency={ticker.currency} currentTicker={currentTicker} />
@ -75,7 +76,7 @@ const TransactionModal = ({
</div>
<footer className={styles.footer}>
<p onClick={() => blockExplorer.showTransaction(transaction.tx_hash)}>{transaction.tx_hash}</p>
<p onClick={() => blockExplorer.showTransaction(isTestnet, transaction.tx_hash)}>{transaction.tx_hash}</p>
</footer>
</div>
)
@ -85,7 +86,9 @@ TransactionModal.propTypes = {
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired,
toggleCurrencyProps: PropTypes.object.isRequired
toggleCurrencyProps: PropTypes.object.isRequired,
isTestnet: PropTypes.bool.isRequired
}
export default TransactionModal

8
app/components/Contacts/Network.js

@ -51,7 +51,9 @@ class Network extends Component {
closeChannel,
suggestedNodesProps
suggestedNodesProps,
isTestnet
} = this.props
const refreshClicked = () => {
@ -224,7 +226,7 @@ class Network extends Component {
<span>{displayNodeName(channel)}</span>
{
selectedChannel === channel &&
<span onClick={() => blockExplorer.showTransaction(channel.channel_point.split(':')[0])}>
<span onClick={() => blockExplorer.showTransaction(isTestnet, channel.channel_point.split(':')[0])}>
<FaExternalLink />
</span>
}
@ -314,6 +316,8 @@ Network.propTypes = {
ticker: PropTypes.object.isRequired,
suggestedNodesProps: PropTypes.object.isRequired,
isTestnet: PropTypes.bool.isRequired,
fetchChannels: PropTypes.func.isRequired,
openContactsForm: PropTypes.func.isRequired,
toggleFilterPulldown: PropTypes.func.isRequired,

6
app/components/ModalRoot/ModalRoot.js

@ -14,7 +14,7 @@ const MODAL_COMPONENTS = {
}
const ModalRoot = ({
modalType, modalProps, hideModal, currentTicker, currency
modalType, modalProps, hideModal, currentTicker, currency, isTestnet
}) => {
if (!modalType) { return null }
@ -31,6 +31,7 @@ const ModalRoot = ({
hideModal={hideModal}
currentTicker={currentTicker}
currency={currency}
isTestnet={isTestnet}
/>
</div>
</div>
@ -42,7 +43,8 @@ ModalRoot.propTypes = {
modalProps: PropTypes.object,
hideModal: PropTypes.func.isRequired,
currentTicker: PropTypes.object.isRequired,
currency: PropTypes.string.isRequired
currency: PropTypes.string.isRequired,
isTestnet: PropTypes.bool.isRequired
}
export default ModalRoot

7
app/components/ModalRoot/SuccessfulSendCoins.js

@ -5,7 +5,7 @@ import { btc, blockExplorer } from 'utils'
import styles from './SuccessfulSendCoins.scss'
const SuccessfulSendCoins = ({
amount, addr, txid, hideModal, currentTicker, currency
amount, addr, txid, hideModal, currentTicker, currency, isTestnet
}) => {
const calculatedAmount = currency === 'usd' ? btc.satoshisToUsd(amount, currentTicker.price_usd) : btc.satoshisToBtc(amount)
@ -14,7 +14,7 @@ const SuccessfulSendCoins = ({
<AnimatedCheckmark />
<h1>
You&nbsp;
<span className={styles.link} onClick={() => blockExplorer.showTransaction(txid)}>sent</span>&nbsp;
<span className={styles.link} onClick={() => blockExplorer.showTransaction(isTestnet, txid)}>sent</span>&nbsp;
<span className={styles.amount}>{calculatedAmount} {currency.toUpperCase()}</span>&nbsp;
to&nbsp;
<span className={styles.addr}>{addr}</span>
@ -35,7 +35,8 @@ SuccessfulSendCoins.propTypes = {
txid: PropTypes.string.isRequired,
hideModal: PropTypes.func.isRequired,
currentTicker: PropTypes.object.isRequired,
currency: PropTypes.string.isRequired
currency: PropTypes.string.isRequired,
isTestnet: PropTypes.bool.isRequired
}
export default SuccessfulSendCoins

6
app/components/Wallet/Wallet.js

@ -26,7 +26,8 @@ const Wallet = ({
currentCurrencyFilters,
currencyName,
setCurrency,
setWalletCurrencyFilters
setWalletCurrencyFilters,
isTestnet
}) => {
const usdAmount = btc.satoshisToUsd((parseInt(balance.walletBalance, 10) + parseInt(balance.channelBalance, 10)), currentTicker.price_usd)
@ -112,7 +113,7 @@ const Wallet = ({
{
// TODO(jimmymow): remove this
// eslint-disable-next-line
}Successfully <span className={styles.txLink} onClick={() => blockExplorer.showTransaction(successTransactionScreen.txid)}>sent</span> transaction
}Successfully <span className={styles.txLink} onClick={() => blockExplorer.showTransaction(isTestnet, successTransactionScreen.txid)}>sent</span> transaction
</section>
</span>
}
@ -133,6 +134,7 @@ Wallet.propTypes = {
openReceiveModal: PropTypes.func.isRequired,
showPayLoadingScreen: PropTypes.bool.isRequired,
showSuccessPayScreen: PropTypes.bool.isRequired,
isTestnet: PropTypes.bool.isRequired,
successTransactionScreen: PropTypes.object.isRequired,
currentCurrencyFilters: PropTypes.array.isRequired,
currencyName: PropTypes.string.isRequired,

1
app/routes/activity/containers/ActivityContainer.js

@ -93,6 +93,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
successTransactionScreen: stateProps.transaction.successTransactionScreen,
currentCurrencyFilters: stateProps.currentCurrencyFilters,
currencyName: stateProps.currencyName,
isTestnet: stateProps.info.data.testnet,
setCurrency: dispatchProps.setCurrency,
setWalletCurrencyFilters: dispatchProps.setWalletCurrencyFilters,

3
app/routes/app/components/App.js

@ -52,6 +52,7 @@ class App extends Component {
ticker,
currentTicker,
form,
info: { data },
formProps,
closeForm,
@ -81,6 +82,7 @@ class App extends Component {
hideModal={hideModal}
currentTicker={currentTicker}
currency={ticker.currency}
isTestnet={data.testnet}
/>
<ContactModal {...contactModalProps} />
@ -114,6 +116,7 @@ App.propTypes = {
formProps: PropTypes.object.isRequired,
closeForm: PropTypes.func.isRequired,
error: PropTypes.object.isRequired,
info: PropTypes.object.isRequired,
currentTicker: PropTypes.object,
contactModalProps: PropTypes.object,
contactsFormProps: PropTypes.object,

2
app/routes/app/containers/AppContainer.js

@ -305,6 +305,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
nodes: stateProps.network.nodes,
nonActiveFilters: stateProps.nonActiveFilters,
ticker: stateProps.ticker,
isTestnet: stateProps.info.data.testnet,
fetchChannels: dispatchProps.fetchChannels,
openContactsForm: dispatchProps.openContactsForm,
@ -361,6 +362,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
modalProps: stateProps.activity.modal.modalProps,
ticker: stateProps.ticker,
currentTicker: stateProps.currentTicker,
isTestnet: stateProps.info.data.testnet,
hideActivityModal: dispatchProps.hideActivityModal,

8
app/utils/blockExplorer.js

@ -3,11 +3,11 @@ 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 showTransaction = (isTestnet, txid) =>
(isTestnet ? shell.openExternal(`${testnetUrl}/tx/${txid}`) : shell.openExternal(`${mainnetUrl}/tx/${txid}`))
const showBlock = blockHash =>
shell.openExternal(`${testnetUrl}/block/${blockHash}`)
const showBlock = (isTestnet, blockHash) =>
(isTestnet ? shell.openExternal(`${testnetUrl}/block/${blockHash}`) : shell.openExternal(`${mainnetUrl}/block/${blockHash}`))
const showChannelClosing = channel =>
showTransaction(channel.closing_txid)

Loading…
Cancel
Save