Browse Source

Merge pull request #161 from Empact/enhance/block-explorer

Extract blockExplorer util
renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
a558ea6852
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/components/Contacts/ClosingContact.js
  2. 5
      app/components/Contacts/PendingContact.js
  3. 5
      app/components/ModalRoot/SuccessfulSendCoins.js
  4. 5
      app/components/Network/ChannelsList.js
  5. 3
      app/reducers/info.js
  6. 5
      app/routes/activity/components/components/Modal/Transaction/Transaction.js
  7. 21
      app/utils/blockExplorer.js
  8. 4
      app/utils/index.js

5
app/components/Contacts/ClosingContact.js

@ -1,8 +1,7 @@
import { shell } from 'electron'
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { FaCircle } from 'react-icons/lib/fa' import { FaCircle } from 'react-icons/lib/fa'
import { btc } from 'utils' import { btc, blockExplorer } from 'utils'
import styles from './Contact.scss' import styles from './Contact.scss'
const ClosingContact = ({ channel }) => ( const ClosingContact = ({ channel }) => (
@ -12,7 +11,7 @@ const ClosingContact = ({ channel }) => (
<FaCircle style={{ verticalAlign: 'top' }} /> <FaCircle style={{ verticalAlign: 'top' }} />
<span> <span>
Removing Removing
<i onClick={() => shell.openExternal(`${'https://testnet.smartbit.com.au'}/tx/${channel.closing_txid}`)}> <i onClick={() => blockExplorer.showChannelClosing(channel)}>
(Details) (Details)
</i> </i>
</span> </span>

5
app/components/Contacts/PendingContact.js

@ -1,8 +1,7 @@
import { shell } from 'electron'
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { FaCircle } from 'react-icons/lib/fa' import { FaCircle } from 'react-icons/lib/fa'
import { btc } from 'utils' import { btc, blockExplorer } from 'utils'
import styles from './Contact.scss' import styles from './Contact.scss'
const PendingContact = ({ channel }) => ( const PendingContact = ({ channel }) => (
@ -12,7 +11,7 @@ const PendingContact = ({ channel }) => (
<FaCircle style={{ verticalAlign: 'top' }} /> <FaCircle style={{ verticalAlign: 'top' }} />
<span> <span>
Pending Pending
<i onClick={() => shell.openExternal(`${'https://testnet.smartbit.com.au'}/tx/${channel.channel.channel_point.split(':')[0]}`)}> <i onClick={() => blockExplorer.showChannelPoint(channel)}>
(Details) (Details)
</i> </i>
</span> </span>

5
app/components/ModalRoot/SuccessfulSendCoins.js

@ -1,8 +1,7 @@
import { shell } from 'electron'
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import AnimatedCheckmark from 'components/AnimatedCheckmark' import AnimatedCheckmark from 'components/AnimatedCheckmark'
import { btc } from 'utils' import { btc, blockExplorer } from 'utils'
import styles from './SuccessfulSendCoins.scss' import styles from './SuccessfulSendCoins.scss'
const SuccessfulSendCoins = ({ const SuccessfulSendCoins = ({
@ -15,7 +14,7 @@ const SuccessfulSendCoins = ({
<AnimatedCheckmark /> <AnimatedCheckmark />
<h1> <h1>
You&nbsp; You&nbsp;
<span className={styles.link} onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${txid}`)}>sent</span>&nbsp; <span className={styles.link} onClick={() => blockExplorer.showTransaction(txid)}>sent</span>&nbsp;
<span className={styles.amount}>{calculatedAmount} {currency.toUpperCase()}</span>&nbsp; <span className={styles.amount}>{calculatedAmount} {currency.toUpperCase()}</span>&nbsp;
to&nbsp; to&nbsp;
<span className={styles.addr}>{addr}</span> <span className={styles.addr}>{addr}</span>

5
app/components/Network/ChannelsList.js

@ -1,7 +1,6 @@
import { shell } from 'electron'
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { btc } from 'utils' import { btc, blockExplorer } from 'utils'
import styles from './ChannelsList.scss' import styles from './ChannelsList.scss'
const ChannelsList = ({ channels, updateSelectedChannels, selectedChannelIds }) => ( const ChannelsList = ({ channels, updateSelectedChannels, selectedChannelIds }) => (
@ -13,7 +12,7 @@ const ChannelsList = ({ channels, updateSelectedChannels, selectedChannelIds })
<header> <header>
<h1>Capacity: {btc.satoshisToBtc(channel.capacity)}</h1> <h1>Capacity: {btc.satoshisToBtc(channel.capacity)}</h1>
<span onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${channel.channel_point.split(':')[0]}`)}>Channel Point</span> <span onClick={() => blockExplorer.showChannelPoint({ channel })}>Channel Point</span>
</header> </header>
<section> <section>

3
app/reducers/info.js

@ -1,5 +1,6 @@
import { createSelector } from 'reselect' import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { blockExplorer } from 'utils'
// ------------------------------------ // ------------------------------------
// Constants // Constants
@ -57,7 +58,7 @@ infoSelectors.isTestnet = createSelector(
infoSelectors.explorerLinkBase = createSelector( infoSelectors.explorerLinkBase = createSelector(
infoSelectors.isTestnet, infoSelectors.isTestnet,
isTestnet => (isTestnet ? 'https://testnet.smartbit.com.au' : 'https://smartbit.com.au') isTestnet => (isTestnet ? blockExplorer.testnetUrl : blockExplorer.mainnetUrl)
) )
export { infoSelectors } export { infoSelectors }

5
app/routes/activity/components/components/Modal/Transaction/Transaction.js

@ -1,11 +1,10 @@
import { shell } from 'electron'
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Moment from 'react-moment' import Moment from 'react-moment'
import 'moment-timezone' import 'moment-timezone'
import { btc } from 'utils' import { btc, blockExplorer } from 'utils'
import styles from './Transaction.scss' import styles from './Transaction.scss'
@ -34,7 +33,7 @@ const Transaction = ({ transaction, ticker, currentTicker }) => (
<i>BTC</i> <i>BTC</i>
</h1> </h1>
</div> </div>
<h3 onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${transaction.tx_hash}`)}>{transaction.tx_hash}</h3> <h3 onClick={() => blockExplorer.showTransaction(transaction.tx_hash)}>{transaction.tx_hash}</h3>
</header> </header>
<dl> <dl>
<dt>Confirmations</dt> <dt>Confirmations</dt>

21
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
}

4
app/utils/index.js

@ -1,9 +1,11 @@
import btc from './btc' import btc from './btc'
import usd from './usd' import usd from './usd'
import bech32 from './bech32' import bech32 from './bech32'
import blockExplorer from './blockExplorer'
export default { export default {
btc, btc,
usd, usd,
bech32 bech32,
blockExplorer
} }

Loading…
Cancel
Save