Browse Source

Merge branch 'master' into feature/new-activity-design

renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
195a9dd2df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/components/Contacts/SubmitChannelForm.js
  2. 40
      app/components/Wallet/Wallet.js
  3. 40
      app/components/Wallet/Wallet.scss
  4. 2
      app/reducers/contactsform.js
  5. 14
      app/reducers/info.js
  6. 3
      app/reducers/ticker.js
  7. 10
      app/routes/activity/containers/ActivityContainer.js
  8. 1
      app/utils/btc.js
  9. 3
      test/reducers/__snapshots__/info.spec.js.snap
  10. 5
      test/reducers/__snapshots__/ticker.spec.js.snap

3
app/components/Contacts/SubmitChannelForm.js

@ -37,6 +37,9 @@ class SubmitChannelForm extends React.Component {
} }
const formSubmitted = () => { const formSubmitted = () => {
// dont submit to LND if they havent set channel capacity amount
if (contactCapacity > 0) { return }
// submit the channel to LND // submit the channel to LND
openChannel({ pubkey: node.pub_key, host: node.addresses[0].addr, local_amt: contactCapacity }) openChannel({ pubkey: node.pub_key, host: node.addresses[0].addr, local_amt: contactCapacity })

40
app/components/Wallet/Wallet.js

@ -7,7 +7,6 @@ import { btc, blockExplorer } from 'utils'
import Value from 'components/Value' import Value from 'components/Value'
import AnimatedCheckmark from 'components/AnimatedCheckmark' import AnimatedCheckmark from 'components/AnimatedCheckmark'
import bitcoinIcon from 'icons/bitcoin.svg'
import zapLogo from 'icons/zap_logo.svg' import zapLogo from 'icons/zap_logo.svg'
import qrCode from 'icons/qrcode.svg' import qrCode from 'icons/qrcode.svg'
@ -23,10 +22,19 @@ const Wallet = ({
openRequestForm, openRequestForm,
showPayLoadingScreen, showPayLoadingScreen,
showSuccessPayScreen, showSuccessPayScreen,
successTransactionScreen successTransactionScreen,
currentCurrencyFilters,
currencyName,
setCurrency,
setWalletCurrencyFilters
}) => { }) => {
const usdAmount = btc.satoshisToUsd((parseInt(balance.walletBalance, 10) + parseInt(balance.channelBalance, 10)), currentTicker.price_usd) const usdAmount = btc.satoshisToUsd((parseInt(balance.walletBalance, 10) + parseInt(balance.channelBalance, 10)), currentTicker.price_usd)
const onCurrencyFilterClick = (currency) => {
setCurrency(currency)
setWalletCurrencyFilters(false)
}
return ( return (
<div className={styles.wallet}> <div className={styles.wallet}>
<div className={styles.content}> <div className={styles.content}>
@ -45,19 +53,31 @@ const Wallet = ({
<div className={styles.left}> <div className={styles.left}>
<div className={styles.leftContent}> <div className={styles.leftContent}>
<Isvg className={styles.bitcoinLogo} src={bitcoinIcon} /> <span onClick={openReceiveModal} className={styles.qrCode}>
<Isvg className={styles.bitcoinLogo} src={qrCode} />
</span>
<div className={styles.details}> <div className={styles.details}>
<h1> <h1>
<span> <span>
<Value <Value
value={parseFloat(balance.walletBalance) + parseFloat(balance.channelBalance)} value={parseFloat(balance.walletBalance) + parseFloat(balance.channelBalance)}
fromCurrency={ticker.fromCurrency}
currency={ticker.currency} currency={ticker.currency}
currentTicker={currentTicker} currentTicker={currentTicker}
/> />
<i className={styles.currency}>{btc.renderCurrency(ticker.currency)}</i> <section className={styles.currencyContainer}>
</span> <i className={styles.currency}>{currencyName}</i>
<span onClick={openReceiveModal}> <span onClick={() => setWalletCurrencyFilters(!info.showWalletCurrencyFilters)}>
<Isvg className={styles.bitcoinLogo} src={qrCode} /> <FaAngleDown />
</span>
<ul className={info.showWalletCurrencyFilters && styles.active}>
{
currentCurrencyFilters.map(filter =>
<li key={filter.key} onClick={() => onCurrencyFilterClick(filter.key)}>{filter.name}</li>)
}
</ul>
</section>
</span> </span>
</h1> </h1>
<span className={styles.usdValue}> ${usdAmount ? usdAmount.toLocaleString() : ''}</span> <span className={styles.usdValue}> ${usdAmount ? usdAmount.toLocaleString() : ''}</span>
@ -113,7 +133,11 @@ Wallet.propTypes = {
openReceiveModal: PropTypes.func.isRequired, openReceiveModal: PropTypes.func.isRequired,
showPayLoadingScreen: PropTypes.bool.isRequired, showPayLoadingScreen: PropTypes.bool.isRequired,
showSuccessPayScreen: PropTypes.bool.isRequired, showSuccessPayScreen: PropTypes.bool.isRequired,
successTransactionScreen: PropTypes.object.isRequired successTransactionScreen: PropTypes.object.isRequired,
currentCurrencyFilters: PropTypes.array.isRequired,
currencyName: PropTypes.string.isRequired,
setCurrency: PropTypes.func.isRequired,
setWalletCurrencyFilters: PropTypes.func.isRequired
} }
export default Wallet export default Wallet

40
app/components/Wallet/Wallet.scss

@ -43,8 +43,12 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
.qrCode {
cursor: pointer;
}
.bitcoinLogo svg { .bitcoinLogo svg {
width: 32px; width: 20px;
height: 32px; height: 32px;
} }
@ -83,6 +87,40 @@
.currency { .currency {
margin-left: 2.5px; margin-left: 2.5px;
} }
.currencyContainer {
position: relative;
display: inline-block;
svg {
width: 25px;
height: 32px;
color: $white;
}
ul {
visibility: hidden;
position: absolute;
top: 30px;
&.active {
visibility: visible;
}
li {
font-size: 12px;
padding: 0px 15px;
background: #191919;
cursor: pointer;
transition: 0.25s hover;
border-bottom: 1px solid #0f0f0f;
&:hover {
background: #0f0f0f;
}
}
}
}
} }
.tickerButtons { .tickerButtons {

2
app/reducers/contactsform.js

@ -15,7 +15,7 @@ const initialState = {
searchQuery: '', searchQuery: '',
manualSearchQuery: '', manualSearchQuery: '',
contactCapacity: 0.1, contactCapacity: 0,
node: {}, node: {},
showErrors: { showErrors: {
manualInput: false manualInput: false

14
app/reducers/info.js

@ -7,6 +7,7 @@ import { blockExplorer } from 'utils'
// ------------------------------------ // ------------------------------------
export const GET_INFO = 'GET_INFO' export const GET_INFO = 'GET_INFO'
export const RECEIVE_INFO = 'RECEIVE_INFO' export const RECEIVE_INFO = 'RECEIVE_INFO'
export const SET_WALLET_CURRENCY_FILTERS = 'SET_WALLET_CURRENCY_FILTERS'
// ------------------------------------ // ------------------------------------
// Actions // Actions
@ -17,6 +18,13 @@ export function getInfo() {
} }
} }
export function setWalletCurrencyFilters(showWalletCurrencyFilters) {
return {
type: SET_WALLET_CURRENCY_FILTERS,
showWalletCurrencyFilters
}
}
// Send IPC event for getinfo // Send IPC event for getinfo
export const fetchInfo = () => async (dispatch) => { export const fetchInfo = () => async (dispatch) => {
dispatch(getInfo()) dispatch(getInfo())
@ -36,7 +44,8 @@ export const receiveInfo = (event, data) => (dispatch) => {
// ------------------------------------ // ------------------------------------
const ACTION_HANDLERS = { const ACTION_HANDLERS = {
[GET_INFO]: state => ({ ...state, infoLoading: true }), [GET_INFO]: state => ({ ...state, infoLoading: true }),
[RECEIVE_INFO]: (state, { data }) => ({ ...state, infoLoading: false, data }) [RECEIVE_INFO]: (state, { data }) => ({ ...state, infoLoading: false, data }),
[SET_WALLET_CURRENCY_FILTERS]: (state, { showWalletCurrencyFilters }) => ({ ...state, showWalletCurrencyFilters })
} }
// ------------------------------------ // ------------------------------------
@ -44,7 +53,8 @@ const ACTION_HANDLERS = {
// ------------------------------------ // ------------------------------------
const initialState = { const initialState = {
infoLoading: false, infoLoading: false,
data: {} data: {},
showWalletCurrencyFilters: false
} }
// Selectors // Selectors

3
app/reducers/ticker.js

@ -64,7 +64,7 @@ export const receiveCryptocurrency = (event, currency) => (dispatch) => {
// Action Handlers // Action Handlers
// ------------------------------------ // ------------------------------------
const ACTION_HANDLERS = { const ACTION_HANDLERS = {
[SET_CURRENCY]: (state, { currency }) => ({ ...state, currency }), [SET_CURRENCY]: (state, { currency }) => ({ ...state, fromCurrency: state.currency, currency }),
[SET_CRYPTO]: (state, { crypto }) => ({ ...state, crypto }), [SET_CRYPTO]: (state, { crypto }) => ({ ...state, crypto }),
[GET_TICKERS]: state => ({ ...state, tickerLoading: true }), [GET_TICKERS]: state => ({ ...state, tickerLoading: true }),
[RECIEVE_TICKERS]: (state, { btcTicker, ltcTicker }) => ( [RECIEVE_TICKERS]: (state, { btcTicker, ltcTicker }) => (
@ -113,6 +113,7 @@ export { tickerSelectors }
const initialState = { const initialState = {
tickerLoading: false, tickerLoading: false,
currency: '', currency: '',
fromCurrency: 'sats',
crypto: '', crypto: '',
btcTicker: null, btcTicker: null,
ltcTicker: null, ltcTicker: null,

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

@ -25,6 +25,8 @@ import { setFormType } from 'reducers/form'
import { payFormSelectors } from 'reducers/payform' import { payFormSelectors } from 'reducers/payform'
import { setWalletCurrencyFilters } from 'reducers/info'
import Activity from '../components/Activity' import Activity from '../components/Activity'
const mapDispatchToProps = { const mapDispatchToProps = {
@ -42,7 +44,8 @@ const mapDispatchToProps = {
openWalletModal, openWalletModal,
fetchBalance, fetchBalance,
updateSearchText, updateSearchText,
setFormType setFormType,
setWalletCurrencyFilters
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
@ -66,6 +69,8 @@ const mapStateToProps = state => ({
invoiceModalOpen: invoiceSelectors.invoiceModalOpen(state), invoiceModalOpen: invoiceSelectors.invoiceModalOpen(state),
currentTicker: tickerSelectors.currentTicker(state), currentTicker: tickerSelectors.currentTicker(state),
currentCurrencyFilters: tickerSelectors.currentCurrencyFilters(state),
currencyName: tickerSelectors.currencyName(state), currencyName: tickerSelectors.currencyName(state),
currentActivity: activitySelectors.currentActivity(state)(state), currentActivity: activitySelectors.currentActivity(state)(state),
@ -84,8 +89,11 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
showPayLoadingScreen: stateProps.showPayLoadingScreen, showPayLoadingScreen: stateProps.showPayLoadingScreen,
showSuccessPayScreen: stateProps.payment.showSuccessPayScreen, showSuccessPayScreen: stateProps.payment.showSuccessPayScreen,
successTransactionScreen: stateProps.transaction.successTransactionScreen, successTransactionScreen: stateProps.transaction.successTransactionScreen,
currentCurrencyFilters: stateProps.currentCurrencyFilters,
currencyName: stateProps.currencyName,
setCurrency: dispatchProps.setCurrency, setCurrency: dispatchProps.setCurrency,
setWalletCurrencyFilters: dispatchProps.setWalletCurrencyFilters,
newAddress: dispatchProps.newAddress, newAddress: dispatchProps.newAddress,
openReceiveModal: dispatchProps.openWalletModal, openReceiveModal: dispatchProps.openWalletModal,
openPayForm: () => dispatchProps.setFormType('PAY_FORM'), openPayForm: () => dispatchProps.setFormType('PAY_FORM'),

1
app/utils/btc.js

@ -52,6 +52,7 @@ export function bitsToUsd(bits, price) {
export function satoshisToBtc(satoshis) { export function satoshisToBtc(satoshis) {
if (satoshis === undefined || satoshis === null || satoshis === '') return null if (satoshis === undefined || satoshis === null || satoshis === '') return null
console.log('satoshis: ', satoshis)
const btcAmount = sb.toBitcoin(satoshis).toFixed(8) const btcAmount = sb.toBitcoin(satoshis).toFixed(8)
return btcAmount > 0 ? btcAmount : btcAmount * -1 return btcAmount > 0 ? btcAmount : btcAmount * -1
} }

3
test/reducers/__snapshots__/info.spec.js.snap

@ -4,6 +4,7 @@ exports[`reducers infoReducer should correctly getInfo 1`] = `
Object { Object {
"data": Object {}, "data": Object {},
"infoLoading": true, "infoLoading": true,
"showWalletCurrencyFilters": false,
} }
`; `;
@ -11,6 +12,7 @@ exports[`reducers infoReducer should correctly receiveInfo 1`] = `
Object { Object {
"data": "foo", "data": "foo",
"infoLoading": false, "infoLoading": false,
"showWalletCurrencyFilters": false,
} }
`; `;
@ -18,5 +20,6 @@ exports[`reducers infoReducer should handle initial state 1`] = `
Object { Object {
"data": Object {}, "data": Object {},
"infoLoading": false, "infoLoading": false,
"showWalletCurrencyFilters": false,
} }
`; `;

5
test/reducers/__snapshots__/ticker.spec.js.snap

@ -19,6 +19,7 @@ Object {
"name": "satoshis", "name": "satoshis",
}, },
], ],
"fromCurrency": "sats",
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": true, "tickerLoading": true,
} }
@ -43,6 +44,7 @@ Object {
"name": "satoshis", "name": "satoshis",
}, },
], ],
"fromCurrency": "sats",
"ltcTicker": undefined, "ltcTicker": undefined,
"tickerLoading": false, "tickerLoading": false,
} }
@ -67,6 +69,7 @@ Object {
"name": "satoshis", "name": "satoshis",
}, },
], ],
"fromCurrency": "sats",
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": false, "tickerLoading": false,
} }
@ -91,6 +94,7 @@ Object {
"name": "satoshis", "name": "satoshis",
}, },
], ],
"fromCurrency": "",
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": false, "tickerLoading": false,
} }
@ -115,6 +119,7 @@ Object {
"name": "satoshis", "name": "satoshis",
}, },
], ],
"fromCurrency": "sats",
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": false, "tickerLoading": false,
} }

Loading…
Cancel
Save