Browse Source

feature(ticker): replace hard coded ticker with currentTicker

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
5a307dfba8
  1. 11
      app/api/index.js
  2. 74
      app/reducers/ticker.js
  3. 5
      app/routes/activity/components/Activity.js
  4. 7
      app/routes/activity/components/components/Invoices.js
  5. 9
      app/routes/activity/components/components/Payments.js
  6. 5
      app/routes/activity/containers/ActivityContainer.js
  7. 3
      app/routes/app/components/App.js
  8. 7
      app/routes/app/components/components/Form/Form.js
  9. 8
      app/routes/app/components/components/Nav.js
  10. 6
      app/routes/app/containers/AppContainer.js
  11. 4
      app/routes/wallet/components/Wallet.js
  12. 20
      app/routes/wallet/components/components/Channels/Channels.js
  13. 6
      app/routes/wallet/components/components/Channels/components/Channel/Channel.js
  14. 6
      app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js
  15. 8
      app/routes/wallet/components/components/Channels/components/ClosedPendingChannel/ClosedPendingChannel.js
  16. 8
      app/routes/wallet/components/components/Channels/components/OpenPendingChannel/OpenPendingChannel.js
  17. 5
      app/routes/wallet/containers/WalletContainer.js

11
app/api/index.js

@ -1,7 +1,7 @@
import axios from 'axios' import axios from 'axios'
export default function requestTicker() { export function requestTicker(id) {
const BASE_URL = 'https://api.coinmarketcap.com/v1/ticker/bitcoin/' const BASE_URL = `https://api.coinmarketcap.com/v1/ticker/${id}/`
return axios({ return axios({
method: 'get', method: 'get',
url: BASE_URL url: BASE_URL
@ -9,3 +9,10 @@ export default function requestTicker() {
.then(response => response.data) .then(response => response.data)
.catch(error => error) .catch(error => error)
} }
export function requestTickers(ids) {
return axios.all(ids.map(id => requestTicker(id)))
.then(axios.spread((btcTicker, ltcTicker) => {
return { btcTicker: btcTicker[0], ltcTicker: ltcTicker[0] }
}))
}

74
app/reducers/ticker.js

@ -1,10 +1,18 @@
import requestTicker from '../api' import { createSelector } from 'reselect'
import { requestTickers } from '../api'
// ------------------------------------ // ------------------------------------
// Constants // Constants
// ------------------------------------ // ------------------------------------
export const SET_CURRENCY = 'SET_CURRENCY' export const SET_CURRENCY = 'SET_CURRENCY'
export const GET_TICKER = 'GET_TICKER' export const SET_CRYPTO = 'SET_CRYPTO'
export const RECIEVE_TICKER = 'RECIEVE_TICKER' export const GET_TICKERS = 'GET_TICKERS'
export const RECIEVE_TICKERS = 'RECIEVE_TICKERS'
// Map for crypto names to crypto tickers
const cryptoTickers = {
bitcoin: 'btc',
litecoin: 'ltc'
}
// ------------------------------------ // ------------------------------------
// Actions // Actions
@ -16,38 +24,69 @@ export function setCurrency(currency) {
} }
} }
export function getTicker() { export function setCrypto(crypto) {
return {
type: SET_CRYPTO,
crypto
}
}
export function getTickers() {
return { return {
type: GET_TICKER type: GET_TICKERS
} }
} }
export function recieveTicker(ticker) { export function recieveTickers({ btcTicker, ltcTicker }) {
return { return {
type: RECIEVE_TICKER, type: RECIEVE_TICKERS,
ticker btcTicker,
ltcTicker
} }
} }
export const fetchTicker = () => async (dispatch) => { export const fetchTicker = (id) => async (dispatch) => {
dispatch(getTicker()) dispatch(getTickers())
const ticker = await requestTicker() const tickers = await requestTickers(['bitcoin', 'litecoin'])
dispatch(recieveTicker(ticker)) dispatch(recieveTickers(tickers))
return ticker return tickers
} }
// Receive IPC event for receiveCryptocurrency
export const receiveCryptocurrency = (event, currency) => dispatch => {
dispatch({ type: SET_CURRENCY, currency: cryptoTickers[currency] })
dispatch({ type: SET_CRYPTO, crypto: cryptoTickers[currency] })
}
// ------------------------------------ // ------------------------------------
// Action Handlers // Action Handlers
// ------------------------------------ // ------------------------------------
const ACTION_HANDLERS = { const ACTION_HANDLERS = {
[SET_CURRENCY]: (state, { currency }) => ({ ...state, currency }), [SET_CURRENCY]: (state, { currency }) => ({ ...state, currency }),
[GET_TICKER]: state => ({ ...state, tickerLoading: true }), [SET_CRYPTO]: (state, { crypto }) => ({ ...state, crypto }),
[RECIEVE_TICKER]: (state, { ticker }) => ( [GET_TICKERS]: state => ({ ...state, tickerLoading: true }),
{ ...state, tickerLoading: false, btcTicker: ticker[0] } [RECIEVE_TICKERS]: (state, { btcTicker, ltcTicker }) => (
{ ...state, tickerLoading: false, btcTicker, ltcTicker }
) )
} }
// Selectors
const tickerSelectors = {}
const cryptoSelector = state => state.ticker.crypto
const bitcoinTickerSelector = state => state.ticker.btcTicker
const litecoinTickerSelector = state => state.ticker.ltcTicker
tickerSelectors.currentTicker = createSelector(
cryptoSelector,
bitcoinTickerSelector,
litecoinTickerSelector,
(crypto, btcTicker, ltcTicker) => crypto === 'btc' ? btcTicker : ltcTicker
)
export { tickerSelectors }
// ------------------------------------ // ------------------------------------
// Reducer // Reducer
// ------------------------------------ // ------------------------------------
@ -55,7 +94,8 @@ const initialState = {
tickerLoading: false, tickerLoading: false,
currency: 'btc', currency: 'btc',
crypto: 'btc', crypto: 'btc',
btcTicker: null btcTicker: null,
ltcTicker: null
} }
export default function tickerReducer(state = initialState, action) { export default function tickerReducer(state = initialState, action) {

5
app/routes/activity/components/Activity.js

@ -31,7 +31,8 @@ class Activity extends Component {
setPayment, setPayment,
setInvoice, setInvoice,
paymentModalOpen, paymentModalOpen,
invoiceModalOpen invoiceModalOpen,
currentTicker
} = this.props } = this.props
if (invoiceLoading || paymentLoading) { return <div>Loading...</div> } if (invoiceLoading || paymentLoading) { return <div>Loading...</div> }
@ -75,6 +76,7 @@ class Activity extends Component {
ticker={ticker} ticker={ticker}
setPayment={setPayment} setPayment={setPayment}
paymentModalOpen={paymentModalOpen} paymentModalOpen={paymentModalOpen}
currentTicker={currentTicker}
/> />
: :
<Invoices <Invoices
@ -83,6 +85,7 @@ class Activity extends Component {
ticker={ticker} ticker={ticker}
setInvoice={setInvoice} setInvoice={setInvoice}
invoiceModalOpen={invoiceModalOpen} invoiceModalOpen={invoiceModalOpen}
currentTicker={currentTicker}
/> />
} }
</div> </div>

7
app/routes/activity/components/components/Invoices.js

@ -14,7 +14,8 @@ const Invoices = ({
invoices, invoices,
ticker, ticker,
setInvoice, setInvoice,
invoiceModalOpen invoiceModalOpen,
currentTicker
}) => ( }) => (
<div> <div>
<Modal isOpen={invoiceModalOpen} resetObject={setInvoice}> <Modal isOpen={invoiceModalOpen} resetObject={setInvoice}>
@ -34,7 +35,7 @@ const Invoices = ({
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(invoice.value) btc.satoshisToBtc(invoice.value)
: :
btc.satoshisToUsd(invoice.value, ticker.btcTicker.price_usd) btc.satoshisToUsd(invoice.value, currentTicker.price_usd)
} }
</span> </span>
</h1> </h1>
@ -91,7 +92,7 @@ const Invoices = ({
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(invoiceItem.value) btc.satoshisToBtc(invoiceItem.value)
: :
btc.satoshisToUsd(invoiceItem.value, ticker.btcTicker.price_usd) btc.satoshisToUsd(invoiceItem.value, currentTicker.price_usd)
} }
</div> </div>
</div> </div>

9
app/routes/activity/components/components/Payments.js

@ -12,7 +12,8 @@ const Payments = ({
payments, payments,
ticker, ticker,
setPayment, setPayment,
paymentModalOpen paymentModalOpen,
currentTicker
}) => ( }) => (
<div> <div>
<Modal isOpen={paymentModalOpen} resetObject={setPayment}> <Modal isOpen={paymentModalOpen} resetObject={setPayment}>
@ -32,7 +33,7 @@ const Payments = ({
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(payment.value) btc.satoshisToBtc(payment.value)
: :
btc.satoshisToUsd(payment.value, ticker.btcTicker.price_usd) btc.satoshisToUsd(payment.value, currentTicker.price_usd)
} }
</span> </span>
</h1> </h1>
@ -81,7 +82,7 @@ const Payments = ({
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(paymentItem.fee) btc.satoshisToBtc(paymentItem.fee)
: :
btc.satoshisToUsd(paymentItem.fee, ticker.btcTicker.price_usd) btc.satoshisToUsd(paymentItem.fee, currentTicker.price_usd)
} }
</span> </span>
</div> </div>
@ -91,7 +92,7 @@ const Payments = ({
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(paymentItem.value) btc.satoshisToBtc(paymentItem.value)
: :
btc.satoshisToUsd(paymentItem.value, ticker.btcTicker.price_usd) btc.satoshisToUsd(paymentItem.value, currentTicker.price_usd)
} }
</span> </span>
</div> </div>

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

@ -1,4 +1,5 @@
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { tickerSelectors } from '../../../reducers/ticker'
import { import {
fetchInvoices, fetchInvoices,
searchInvoices, searchInvoices,
@ -31,7 +32,9 @@ const mapStateToProps = state => ({
ticker: state.ticker, ticker: state.ticker,
paymentModalOpen: paymentSelectors.paymentModalOpen(state), paymentModalOpen: paymentSelectors.paymentModalOpen(state),
invoiceModalOpen: invoiceSelectors.invoiceModalOpen(state) invoiceModalOpen: invoiceSelectors.invoiceModalOpen(state),
currentTicker: tickerSelectors.currentTicker(state)
}) })
export default connect(mapStateToProps, mapDispatchToProps)(Activity) export default connect(mapStateToProps, mapDispatchToProps)(Activity)

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

@ -29,6 +29,7 @@ class App extends Component {
createInvoice, createInvoice,
payInvoice, payInvoice,
fetchInvoice, fetchInvoice,
currentTicker,
children children
} = this.props } = this.props
@ -49,12 +50,14 @@ class App extends Component {
payInvoice={payInvoice} payInvoice={payInvoice}
fetchInvoice={fetchInvoice} fetchInvoice={fetchInvoice}
formInvoice={formInvoice} formInvoice={formInvoice}
currentTicker={currentTicker}
/> />
<Nav <Nav
ticker={ticker} ticker={ticker}
balance={balance} balance={balance}
setCurrency={setCurrency} setCurrency={setCurrency}
formClicked={formType => setForm({ modalOpen: true, formType })} formClicked={formType => setForm({ modalOpen: true, formType })}
currentTicker={currentTicker}
/> />
<div className={styles.content}> <div className={styles.content}>
{children} {children}

7
app/routes/app/components/components/Form/Form.js

@ -16,10 +16,11 @@ const Form = ({
createInvoice, createInvoice,
payInvoice, payInvoice,
fetchInvoice, fetchInvoice,
formInvoice formInvoice,
currentTicker
}) => { }) => {
const requestClicked = () => { const requestClicked = () => {
createInvoice(amount, message, currency, btcTicker.price_usd) createInvoice(amount, message, currency, currentTicker.price_usd)
close() close()
} }
@ -33,7 +34,7 @@ const Form = ({
if (payreq.length === 124) { fetchInvoice(payreq) } if (payreq.length === 124) { fetchInvoice(payreq) }
} }
const calculateAmount = value => (currency === 'btc' ? btc.satoshisToBtc(value) : btc.satoshisToUsd(value, btcTicker.price_usd)) const calculateAmount = value => (currency === 'btc' ? btc.satoshisToBtc(value) : btc.satoshisToUsd(value, currentTicker.price_usd))
return ( return (
<div className={`${styles.formContainer} ${isOpen ? styles.open : ''}`}> <div className={`${styles.formContainer} ${isOpen ? styles.open : ''}`}>

8
app/routes/app/components/components/Nav.js

@ -7,12 +7,12 @@ import { FaClockO, FaBitcoin, FaDollar } from 'react-icons/lib/fa'
import { btc } from '../../../../utils' import { btc } from '../../../../utils'
import styles from './Nav.scss' import styles from './Nav.scss'
const Nav = ({ ticker, balance, setCurrency, formClicked }) => ( const Nav = ({ ticker, balance, setCurrency, formClicked, currentTicker }) => (
<nav className={styles.nav}> <nav className={styles.nav}>
<ul className={styles.info}> <ul className={styles.info}>
<li className={`${styles.currencies} ${styles.link}`}> <li className={`${styles.currencies} ${styles.link}`}>
<span <span
data-hint={ticker.btcTicker ? ticker.btcTicker.price_usd : null} data-hint={currentTicker ? currentTicker.price_usd : null}
className={`${styles.currency} ${ticker.currency === 'btc' ? styles.active : ''} hint--bottom`} className={`${styles.currency} ${ticker.currency === 'btc' ? styles.active : ''} hint--bottom`}
onClick={() => setCurrency('btc')} onClick={() => setCurrency('btc')}
> >
@ -33,7 +33,7 @@ const Nav = ({ ticker, balance, setCurrency, formClicked }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(balance.walletBalance) btc.satoshisToBtc(balance.walletBalance)
: :
btc.satoshisToUsd(balance.walletBalance, ticker.btcTicker.price_usd) btc.satoshisToUsd(balance.walletBalance, currentTicker.price_usd)
} }
</span> </span>
</p> </p>
@ -46,7 +46,7 @@ const Nav = ({ ticker, balance, setCurrency, formClicked }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(balance.channelBalance) btc.satoshisToBtc(balance.channelBalance)
: :
btc.satoshisToUsd(balance.channelBalance, ticker.btcTicker.price_usd) btc.satoshisToUsd(balance.channelBalance, currentTicker.price_usd)
} }
</span> </span>
</p> </p>

6
app/routes/app/containers/AppContainer.js

@ -1,6 +1,6 @@
import { connect } from 'react-redux' import { connect } from 'react-redux'
import App from '../components/App' import App from '../components/App'
import { fetchTicker, setCurrency } from '../../../reducers/ticker' import { fetchTicker, setCurrency, tickerSelectors } from '../../../reducers/ticker'
import { fetchBalance } from '../../../reducers/balance' import { fetchBalance } from '../../../reducers/balance'
import { fetchInfo } from '../../../reducers/info' import { fetchInfo } from '../../../reducers/info'
import { createInvoice, fetchInvoice } from '../../../reducers/invoice' import { createInvoice, fetchInvoice } from '../../../reducers/invoice'
@ -35,7 +35,9 @@ const mapStateToProps = state => ({
balance: state.balance, balance: state.balance,
payment: state.payment, payment: state.payment,
form: state.form, form: state.form,
invoice: state.invoice invoice: state.invoice,
currentTicker: tickerSelectors.currentTicker(state)
}) })
export default connect(mapStateToProps, mapDispatchToProps)(App) export default connect(mapStateToProps, mapDispatchToProps)(App)

4
app/routes/wallet/components/Wallet.js

@ -31,7 +31,8 @@ class Wallet extends Component {
connectRequest, connectRequest,
disconnectRequest, disconnectRequest,
allChannels, allChannels,
openChannel openChannel,
currentTicker
} = this.props } = this.props
return ( return (
@ -74,6 +75,7 @@ class Wallet extends Component {
channelForm={channelForm} channelForm={channelForm}
setChannelForm={setChannelForm} setChannelForm={setChannelForm}
openChannel={openChannel} openChannel={openChannel}
currentTicker={currentTicker}
/> />
</section> </section>
</div> </div>

20
app/routes/wallet/components/components/Channels/Channels.js

@ -18,11 +18,12 @@ const Channels = ({
channelForm, channelForm,
setChannelForm, setChannelForm,
allChannels, allChannels,
openChannel openChannel,
currentTicker
}) => ( }) => (
<div className={styles.channels}> <div className={styles.channels}>
<ChannelModal isOpen={channelModalOpen} resetChannel={setChannel} channel={modalChannel} /> <ChannelModal isOpen={channelModalOpen} resetChannel={setChannel} channel={modalChannel} />
<ChannelForm form={channelForm} setForm={setChannelForm} ticker={ticker} peers={peers} openChannel={openChannel} /> <ChannelForm form={channelForm} setForm={setChannelForm} ticker={ticker} peers={peers} openChannel={openChannel} currentTicker={currentTicker} />
<div className={styles.header}> <div className={styles.header}>
<h3>Channels</h3> <h3>Channels</h3>
<div <div
@ -39,11 +40,21 @@ const Channels = ({
allChannels.map((channel, index) => { allChannels.map((channel, index) => {
if (Object.prototype.hasOwnProperty.call(channel, 'blocks_till_open')) { if (Object.prototype.hasOwnProperty.call(channel, 'blocks_till_open')) {
return ( return (
<OpenPendingChannel key={index} channel={channel} ticker={ticker} /> <OpenPendingChannel
key={index}
channel={channel}
ticker={ticker}
currentTicker={currentTicker}
/>
) )
} else if (Object.prototype.hasOwnProperty.call(channel, 'closing_txid')) { } else if (Object.prototype.hasOwnProperty.call(channel, 'closing_txid')) {
return ( return (
<ClosedPendingChannel key={index} channel={channel} ticker={ticker} /> <ClosedPendingChannel
key={index}
channel={channel}
ticker={ticker}
currentTicker={currentTicker}
/>
) )
} }
return ( return (
@ -52,6 +63,7 @@ const Channels = ({
ticker={ticker} ticker={ticker}
channel={channel} channel={channel}
setChannel={setChannel} setChannel={setChannel}
currentTicker={currentTicker}
/> />
) )
}) })

6
app/routes/wallet/components/components/Channels/components/Channel/Channel.js

@ -24,7 +24,7 @@ const Channel = ({ ticker, channel, setChannel }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.capacity) btc.satoshisToBtc(channel.capacity)
: :
btc.satoshisToUsd(channel.capacity, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.capacity, currentTicker.price_usd)
} }
</h2> </h2>
</section> </section>
@ -35,7 +35,7 @@ const Channel = ({ ticker, channel, setChannel }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.local_balance) btc.satoshisToBtc(channel.local_balance)
: :
btc.satoshisToUsd(channel.local_balance, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.local_balance, currentTicker.price_usd)
} }
</h4> </h4>
<span>Local</span> <span>Local</span>
@ -46,7 +46,7 @@ const Channel = ({ ticker, channel, setChannel }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.remote_balance) btc.satoshisToBtc(channel.remote_balance)
: :
btc.satoshisToUsd(channel.remote_balance, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.remote_balance, currentTicker.price_usd)
} }
</h4> </h4>
<span>Remote</span> <span>Remote</span>

6
app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js

@ -5,12 +5,12 @@ import { FaUser, FaBitcoin, FaDollar } from 'react-icons/lib/fa'
import { usd, btc } from '../../../../../../../utils' import { usd, btc } from '../../../../../../../utils'
import styles from './ChannelForm.scss' import styles from './ChannelForm.scss'
const ChannelForm = ({ form, setForm, ticker, peers, openChannel }) => { const ChannelForm = ({ form, setForm, ticker, peers, openChannel, currentTicker }) => {
const submitClicked = () => { const submitClicked = () => {
const { node_key, local_amt, push_amt } = form const { node_key, local_amt, push_amt } = form
const localamt = ticker.currency === 'btc' ? btc.btcToSatoshis(local_amt) : btc.btcToSatoshis(usd.usdToBtc(local_amt, ticker.btcTicker.price_usd)) const localamt = ticker.currency === 'btc' ? btc.btcToSatoshis(local_amt) : btc.btcToSatoshis(usd.usdToBtc(local_amt, currentTicker.price_usd))
const pushamt = ticker.currency === 'btc' ? btc.btcToSatoshis(push_amt) : btc.btcToSatoshis(usd.usdToBtc(push_amt, ticker.btcTicker.price_usd)) const pushamt = ticker.currency === 'btc' ? btc.btcToSatoshis(push_amt) : btc.btcToSatoshis(usd.usdToBtc(push_amt, currentTicker.price_usd))
openChannel({ pubkey: node_key, localamt, pushamt }) openChannel({ pubkey: node_key, localamt, pushamt })
setForm({ isOpen: false }) setForm({ isOpen: false })

8
app/routes/wallet/components/components/Channels/components/ClosedPendingChannel/ClosedPendingChannel.js

@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import { btc } from '../../../../../../../utils' import { btc } from '../../../../../../../utils'
import styles from './ClosedPendingChannel.scss' import styles from './ClosedPendingChannel.scss'
const ClosedPendingChannel = ({ ticker, channel: { channel, closing_txid } }) => ( const ClosedPendingChannel = ({ ticker, channel: { channel, closing_txid }, currentTicker }) => (
<li className={styles.channel} onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${closing_txid}`)}> <li className={styles.channel} onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${closing_txid}`)}>
<h1 className={styles.closing}>Status: Closing</h1> <h1 className={styles.closing}>Status: Closing</h1>
<div className={styles.left}> <div className={styles.left}>
@ -25,7 +25,7 @@ const ClosedPendingChannel = ({ ticker, channel: { channel, closing_txid } }) =>
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.capacity) btc.satoshisToBtc(channel.capacity)
: :
btc.satoshisToUsd(channel.capacity, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.capacity, currentTicker.price_usd)
} }
</h2> </h2>
</section> </section>
@ -36,7 +36,7 @@ const ClosedPendingChannel = ({ ticker, channel: { channel, closing_txid } }) =>
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.local_balance) btc.satoshisToBtc(channel.local_balance)
: :
btc.satoshisToUsd(channel.local_balance, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.local_balance, currentTicker.price_usd)
} }
</h4> </h4>
<span>Local</span> <span>Local</span>
@ -47,7 +47,7 @@ const ClosedPendingChannel = ({ ticker, channel: { channel, closing_txid } }) =>
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.remote_balance) btc.satoshisToBtc(channel.remote_balance)
: :
btc.satoshisToUsd(channel.remote_balance, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.remote_balance, currentTicker.price_usd)
} }
</h4> </h4>
<span>Remote</span> <span>Remote</span>

8
app/routes/wallet/components/components/Channels/components/OpenPendingChannel/OpenPendingChannel.js

@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import { btc } from '../../../../../../../utils' import { btc } from '../../../../../../../utils'
import styles from './OpenPendingChannel.scss' import styles from './OpenPendingChannel.scss'
const OpenPendingChannel = ({ ticker, channel: { channel } }) => ( const OpenPendingChannel = ({ ticker, channel: { channel }, currentTicker }) => (
<li className={styles.channel} onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${channel.channel_point.split(':')[0]}`)}> <li className={styles.channel} onClick={() => shell.openExternal(`https://testnet.smartbit.com.au/tx/${channel.channel_point.split(':')[0]}`)}>
<h1 className={styles.pending}>Status: Pending</h1> <h1 className={styles.pending}>Status: Pending</h1>
<div className={styles.left}> <div className={styles.left}>
@ -25,7 +25,7 @@ const OpenPendingChannel = ({ ticker, channel: { channel } }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.capacity) btc.satoshisToBtc(channel.capacity)
: :
btc.satoshisToUsd(channel.capacity, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.capacity, currentTicker.price_usd)
} }
</h2> </h2>
</section> </section>
@ -36,7 +36,7 @@ const OpenPendingChannel = ({ ticker, channel: { channel } }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.local_balance) btc.satoshisToBtc(channel.local_balance)
: :
btc.satoshisToUsd(channel.local_balance, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.local_balance, currentTicker.price_usd)
} }
</h4> </h4>
<span>Local</span> <span>Local</span>
@ -47,7 +47,7 @@ const OpenPendingChannel = ({ ticker, channel: { channel } }) => (
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.remote_balance) btc.satoshisToBtc(channel.remote_balance)
: :
btc.satoshisToUsd(channel.remote_balance, ticker.btcTicker.price_usd) btc.satoshisToUsd(channel.remote_balance, currentTicker.price_usd)
} }
</h4> </h4>
<span>Remote</span> <span>Remote</span>

5
app/routes/wallet/containers/WalletContainer.js

@ -1,6 +1,7 @@
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { newAddress } from '../../../reducers/address' import { newAddress } from '../../../reducers/address'
import { fetchInfo } from '../../../reducers/info' import { fetchInfo } from '../../../reducers/info'
import { tickerSelectors } from '../../../reducers/ticker'
import { import {
fetchPeers, fetchPeers,
setPeer, setPeer,
@ -49,7 +50,9 @@ const mapStateToProps = state => ({
allChannels: channelsSelectors.allChannels(state), allChannels: channelsSelectors.allChannels(state),
peerModalOpen: peersSelectors.peerModalOpen(state), peerModalOpen: peersSelectors.peerModalOpen(state),
channelModalOpen: channelsSelectors.channelModalOpen(state) channelModalOpen: channelsSelectors.channelModalOpen(state),
currentTicker: tickerSelectors.currentTicker(state)
}) })
export default connect(mapStateToProps, mapDispatchToProps)(Wallet) export default connect(mapStateToProps, mapDispatchToProps)(Wallet)

Loading…
Cancel
Save