From a6111c3dd5934007f26ae8bf408c738ca9925c84 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 19 Sep 2017 14:17:36 -0500 Subject: [PATCH 01/21] feature(txs): setup getTransactions and hook up to new reducer --- app/lnd/methods/index.js | 5 + app/reducers/index.js | 4 +- app/reducers/ipc.js | 5 +- app/reducers/transaction.js | 93 +++++++++++++++++++ app/routes/activity/components/Activity.js | 3 +- .../activity/containers/ActivityContainer.js | 2 + 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 app/reducers/transaction.js diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index a891a453..9b69ec2f 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -49,6 +49,11 @@ export default function (lnd, event, msg, data) { ) .catch(error => console.log('channels error: ', error)) break + case 'transactions': + // Data looks like { transactions: [] } + walletController.getTransactions(lnd) + .then(transactionsData => event.sender.send('receiveTransactions', transactionsData)) + .catch(error => console.log('transactions error: ', error)) case 'payments': // Data looks like { payments: [] } paymentsController.listPayments(lnd) diff --git a/app/reducers/index.js b/app/reducers/index.js index c736b6e3..75b0597e 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -11,6 +11,7 @@ import form from './form' import invoice from './invoice' import modal from './modal' import address from './address' +import transaction from './transaction' const rootReducer = combineReducers({ router, @@ -23,7 +24,8 @@ const rootReducer = combineReducers({ form, invoice, modal, - address + address, + transaction }) export default rootReducer diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js index 78988e07..2f035923 100644 --- a/app/reducers/ipc.js +++ b/app/reducers/ipc.js @@ -22,6 +22,7 @@ import { import { receivePayments, paymentSuccessful, sendSuccessful, sendCoinsError } from './payment' import { receiveInvoices, createdInvoice, receiveFormInvoice } from './invoice' import { receiveBalance } from './balance' +import { receiveTransactions } from './transaction' // Import all receiving IPC event handlers and pass them into createIpc const ipc = createIpc({ @@ -58,7 +59,9 @@ const ipc = createIpc({ disconnectSuccess, receiveAddress, - receiveCryptocurrency + receiveCryptocurrency, + + receiveTransactions }) export default ipc diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js new file mode 100644 index 00000000..e671e324 --- /dev/null +++ b/app/reducers/transaction.js @@ -0,0 +1,93 @@ +import { createSelector } from 'reselect' +import { ipcRenderer } from 'electron' +import { btc, usd } from '../utils' +import { setForm, resetForm } from './form' +import { showModal } from './modal' + +// ------------------------------------ +// Constants +// ------------------------------------ +export const GET_TRANSACTIONS = 'GET_TRANSACTIONS' +export const RECEIVE_TRANSACTIONS = 'RECEIVE_TRANSACTIONS' + +export const SEND_TRANSACTION = 'SEND_TRANSACTION' + +export const TRANSACTION_SUCCESSFULL = 'TRANSACTION_SUCCESSFULL' +export const TRANSACTION_FAILED = 'TRANSACTION_FAILED' + +// ------------------------------------ +// Actions +// ------------------------------------ +export function getTransactions() { + return { + type: GET_TRANSACTIONS + } +} + +export function sendTransaction() { + return { + type: SEND_TRANSACTION + } +} + +// Send IPC event for payments +export const fetchTransactions = () => (dispatch) => { + dispatch(getTransactions()) + ipcRenderer.send('lnd', { msg: 'transactions' }) +} + +// Receive IPC event for payments +export const receiveTransactions = (event, { transactions }) => dispatch => dispatch({ type: RECEIVE_TRANSACTIONS, transactions }) + +export const sendCoins = ({ value, addr, currency, rate }) => (dispatch) => { + const amount = currency === 'usd' ? btc.btcToSatoshis(usd.usdToBtc(value, rate)) : btc.btcToSatoshis(value) + dispatch(sendPayment()) + ipcRenderer.send('lnd', { msg: 'sendCoins', data: { amount, addr } }) +} + +// Receive IPC event for successful payment +// TODO: Add payment to state, not a total re-fetch +export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatch) => { + // Get the new list of transactions (TODO dont do an entire new fetch) + fetchTransactions() + // Close the form modal once the payment was succesful + dispatch(setForm({ modalOpen: false })) + // Show successful payment state + dispatch(showModal('SUCCESSFUL_SEND_COINS', { txid, amount, addr })) + // TODO: Add successful on-chain payment to payments list once payments list supports on-chain and LN + // dispatch({ type: PAYMENT_SUCCESSFULL, payment: { amount, addr, txid, pending: true } }) + dispatch({ type: TRANSACTION_SUCCESSFULL }) + // Reset the payment form + dispatch(resetForm()) +} + +export const transactionError = () => (dispatch) => { + dispatch({ type: PAYMENT_FAILED }) +} + + +// ------------------------------------ +// Action Handlers +// ------------------------------------ +const ACTION_HANDLERS = { + [GET_TRANSACTIONS]: state => ({ ...state, transactionLoading: true }), + [SEND_TRANSACTION]: state => ({ ...state, sendingTransaction: true }), + [RECEIVE_TRANSACTIONS]: (state, { transactions }) => ({ ...state, transactionLoading: false, transactions }), + [TRANSACTION_SUCCESSFULL]: state => ({ ...state, sendingTransaction: false }), + [TRANSACTION_FAILED]: state => ({ ...state, sendingTransaction: false }) +} + +// ------------------------------------ +// Reducer +// ------------------------------------ +const initialState = { + sendingtransaction: false, + transactionLoading: false, + transactions: [] +} + +export default function transactionReducer(state = initialState, action) { + const handler = ACTION_HANDLERS[action.type] + + return handler ? handler(state, action) : state +} diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index 85692c8e..be61ab6a 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -14,10 +14,11 @@ class Activity extends Component { } componentWillMount() { - const { fetchPayments, fetchInvoices } = this.props + const { fetchPayments, fetchInvoices, fetchTransactions } = this.props fetchPayments() fetchInvoices() + fetchTransactions() } render() { diff --git a/app/routes/activity/containers/ActivityContainer.js b/app/routes/activity/containers/ActivityContainer.js index 1b3cba45..25f0652e 100644 --- a/app/routes/activity/containers/ActivityContainer.js +++ b/app/routes/activity/containers/ActivityContainer.js @@ -11,6 +11,7 @@ import { fetchPayments, paymentSelectors } from '../../../reducers/payment' +import { fetchTransactions } from '../../../reducers/transaction' import Activity from '../components/Activity' const mapDispatchToProps = { @@ -18,6 +19,7 @@ const mapDispatchToProps = { setInvoice, fetchPayments, fetchInvoices, + fetchTransactions, searchInvoices } From e7a819c3867c11f37b00ce449845bbc0aac44c8c Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 19 Sep 2017 14:30:52 -0500 Subject: [PATCH 02/21] fix(sendcoins): move sendcoins to new transaction reducer, remove unused code from payments --- app/lnd/methods/index.js | 4 ++-- app/reducers/ipc.js | 10 ++++----- app/reducers/payment.js | 22 ------------------- app/reducers/transaction.js | 4 ++-- app/routes/app/components/App.js | 3 +++ .../app/components/components/Form/Form.js | 8 ++++--- .../components/Form/components/Pay/Pay.js | 6 ++--- app/routes/app/containers/AppContainer.js | 4 +++- 8 files changed, 23 insertions(+), 38 deletions(-) diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index 9b69ec2f..eca3b570 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -101,8 +101,8 @@ export default function (lnd, event, msg, data) { // Transaction looks like { txid: String } // { amount, addr } = data walletController.sendCoins(lnd, data) - .then(({ txid }) => event.sender.send('sendSuccessful', { amount: data.amount, addr: data.addr, txid })) - .catch(error => event.sender.send('sendCoinsError', { error })) + .then(({ txid }) => event.sender.send('transactionSuccessful', { amount: data.amount, addr: data.addr, txid })) + .catch(error => event.sender.send('transactionError', { error })) break case 'openChannel': // Response is empty. Streaming updates on channel status and updates diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js index 2f035923..c61ccd20 100644 --- a/app/reducers/ipc.js +++ b/app/reducers/ipc.js @@ -19,10 +19,10 @@ import { pushclosechannelstatus } from './channels' -import { receivePayments, paymentSuccessful, sendSuccessful, sendCoinsError } from './payment' +import { receivePayments, paymentSuccessful } from './payment' import { receiveInvoices, createdInvoice, receiveFormInvoice } from './invoice' import { receiveBalance } from './balance' -import { receiveTransactions } from './transaction' +import { receiveTransactions, transactionSuccessful, transactionError } from './transaction' // Import all receiving IPC event handlers and pass them into createIpc const ipc = createIpc({ @@ -41,8 +41,6 @@ const ipc = createIpc({ receiveBalance, paymentSuccessful, - sendSuccessful, - sendCoinsError, channelSuccessful, pushchannelupdated, @@ -61,7 +59,9 @@ const ipc = createIpc({ receiveAddress, receiveCryptocurrency, - receiveTransactions + receiveTransactions, + transactionSuccessful, + transactionError }) export default ipc diff --git a/app/reducers/payment.js b/app/reducers/payment.js index 4bfdf453..7a04bd7b 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -66,32 +66,10 @@ export const payInvoice = paymentRequest => (dispatch) => { ipcRenderer.send('lnd', { msg: 'sendPayment', data: { paymentRequest } }) } -export const sendCoins = ({ value, addr, currency, rate }) => (dispatch) => { - const amount = currency === 'usd' ? btc.btcToSatoshis(usd.usdToBtc(value, rate)) : btc.btcToSatoshis(value) - dispatch(sendPayment()) - ipcRenderer.send('lnd', { msg: 'sendCoins', data: { amount, addr } }) -} - // Receive IPC event for successful payment // TODO: Add payment to state, not a total re-fetch export const paymentSuccessful = () => fetchPayments() -export const sendSuccessful = (event, { amount, addr, txid }) => (dispatch) => { - // Close the form modal once the payment was succesful - dispatch(setForm({ modalOpen: false })) - // Show successful payment state - dispatch(showModal('SUCCESSFUL_SEND_COINS', { txid, amount, addr })) - // TODO: Add successful on-chain payment to payments list once payments list supports on-chain and LN - // dispatch({ type: PAYMENT_SUCCESSFULL, payment: { amount, addr, txid, pending: true } }) - dispatch({ type: PAYMENT_SUCCESSFULL }) - // Reset the payment form - dispatch(resetForm()) -} - -export const sendCoinsError = () => (dispatch) => { - dispatch({ type: PAYMENT_FAILED }) -} - // ------------------------------------ // Action Handlers diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index e671e324..c551ff24 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -41,7 +41,7 @@ export const receiveTransactions = (event, { transactions }) => dispatch => disp export const sendCoins = ({ value, addr, currency, rate }) => (dispatch) => { const amount = currency === 'usd' ? btc.btcToSatoshis(usd.usdToBtc(value, rate)) : btc.btcToSatoshis(value) - dispatch(sendPayment()) + dispatch(sendTransaction()) ipcRenderer.send('lnd', { msg: 'sendCoins', data: { amount, addr } }) } @@ -81,7 +81,7 @@ const ACTION_HANDLERS = { // Reducer // ------------------------------------ const initialState = { - sendingtransaction: false, + sendingTransaction: false, transactionLoading: false, transactions: [] } diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 421be3fc..d2a01579 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -28,6 +28,7 @@ class App extends Component { setPubkey, setPaymentRequest, payment, + transaction: { sendingTransaction }, peers, setCurrency, setForm, @@ -64,6 +65,7 @@ class App extends Component { peers={peers} ticker={ticker} form={form} + sendingTransaction={sendingTransaction} createInvoice={createInvoice} payInvoice={payInvoice} sendCoins={sendCoins} @@ -103,6 +105,7 @@ App.propTypes = { setPubkey: PropTypes.func.isRequired, setPaymentRequest: PropTypes.func.isRequired, payment: PropTypes.object.isRequired, + transaction: PropTypes.object.isRequired, peers: PropTypes.array, setCurrency: PropTypes.func.isRequired, setForm: PropTypes.func.isRequired, diff --git a/app/routes/app/components/components/Form/Form.js b/app/routes/app/components/components/Form/Form.js index a57dafe9..e753d61a 100644 --- a/app/routes/app/components/components/Form/Form.js +++ b/app/routes/app/components/components/Form/Form.js @@ -22,7 +22,8 @@ const Form = ({ formInvoice, currentTicker, isOnchain, - isLn + isLn, + sendingTransaction }) => (
@@ -33,7 +34,7 @@ const Form = ({ { formType === 'pay' ? { - sendingPayment ? + sendingTransaction ? : null @@ -127,7 +127,7 @@ class Pay extends Component { } Pay.propTypes = { - sendingPayment: PropTypes.bool.isRequired, + sendingTransaction: PropTypes.bool.isRequired, invoiceAmount: PropTypes.string.isRequired, onchainAmount: PropTypes.string.isRequired, setOnchainAmount: PropTypes.func.isRequired, diff --git a/app/routes/app/containers/AppContainer.js b/app/routes/app/containers/AppContainer.js index 3f2e8153..27961910 100644 --- a/app/routes/app/containers/AppContainer.js +++ b/app/routes/app/containers/AppContainer.js @@ -5,7 +5,8 @@ import { fetchBalance } from '../../../reducers/balance' import { fetchInfo } from '../../../reducers/info' import { createInvoice, fetchInvoice } from '../../../reducers/invoice' import { hideModal } from '../../../reducers/modal' -import { payInvoice, sendCoins } from '../../../reducers/payment' +import { payInvoice } from '../../../reducers/payment' +import { sendCoins } from '../../../reducers/transaction' import { fetchChannels } from '../../../reducers/channels' import { setForm, @@ -42,6 +43,7 @@ const mapStateToProps = state => ({ ticker: state.ticker, balance: state.balance, payment: state.payment, + transaction: state.transaction, form: state.form, invoice: state.invoice, modal: state.modal, From c1853cc5f810693e9a80fab90a09b891646d2de7 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 19 Sep 2017 14:49:45 -0500 Subject: [PATCH 03/21] feature(activity): create selectors folder for specific selectors. sortedActivity for all payments, invoices, txs sorted by timestamp --- app/routes/activity/components/Activity.js | 5 +++-- .../activity/containers/ActivityContainer.js | 6 ++++- app/selectors/activity.js | 22 +++++++++++++++++++ app/selectors/index.js | 5 +++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 app/selectors/activity.js create mode 100644 app/selectors/index.js diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index be61ab6a..064ac5f1 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -33,9 +33,10 @@ class Activity extends Component { setInvoice, paymentModalOpen, invoiceModalOpen, - currentTicker + currentTicker, + sortedActivity } = this.props - + console.log('sortedActivity: ', sortedActivity) if (invoiceLoading || paymentLoading) { return
Loading...
} return (
diff --git a/app/routes/activity/containers/ActivityContainer.js b/app/routes/activity/containers/ActivityContainer.js index 25f0652e..35658ed7 100644 --- a/app/routes/activity/containers/ActivityContainer.js +++ b/app/routes/activity/containers/ActivityContainer.js @@ -12,6 +12,7 @@ import { paymentSelectors } from '../../../reducers/payment' import { fetchTransactions } from '../../../reducers/transaction' +import { activitySelectors } from '../../../selectors' import Activity from '../components/Activity' const mapDispatchToProps = { @@ -23,6 +24,7 @@ const mapDispatchToProps = { searchInvoices } +console.log('activitySelectors: ', activitySelectors) const mapStateToProps = state => ({ activity: state.activity, @@ -36,7 +38,9 @@ const mapStateToProps = state => ({ paymentModalOpen: paymentSelectors.paymentModalOpen(state), invoiceModalOpen: invoiceSelectors.invoiceModalOpen(state), - currentTicker: tickerSelectors.currentTicker(state) + currentTicker: tickerSelectors.currentTicker(state), + + sortedActivity: activitySelectors.sortedActivity(state) }) export default connect(mapStateToProps, mapDispatchToProps)(Activity) diff --git a/app/selectors/activity.js b/app/selectors/activity.js new file mode 100644 index 00000000..7d89239c --- /dev/null +++ b/app/selectors/activity.js @@ -0,0 +1,22 @@ +import { createSelector } from 'reselect' + +const activitySelectors = {} +const paymentsSelector = state => state.payment.payments +const invoicesSelector = state => state.invoice.invoices +const transactionsSelector = state => state.transaction.transactions + +activitySelectors.sortedActivity = createSelector( + paymentsSelector, + invoicesSelector, + transactionsSelector, + (payments, invoices, transactions) => { + return [...payments, ...invoices, ...transactions].sort((a, b) => { + let aTimestamp = a.hasOwnProperty('time_stamp') ? a.time_stamp : a.creation_date + let bTimestamp = b.hasOwnProperty('time_stamp') ? b.time_stamp : b.creation_date + + return bTimestamp - aTimestamp + }) + } +) + +export default activitySelectors \ No newline at end of file diff --git a/app/selectors/index.js b/app/selectors/index.js new file mode 100644 index 00000000..f28a76aa --- /dev/null +++ b/app/selectors/index.js @@ -0,0 +1,5 @@ +import activitySelectors from './activity' + +export default { + activitySelectors +} \ No newline at end of file From 0a04874e52b9c2fda80aa6f1b8ec23e3ee2a9fa2 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 19 Sep 2017 19:19:33 -0500 Subject: [PATCH 04/21] create components for each type of activity / fix modal not closing on successful payment --- app/reducers/payment.js | 11 ++++- app/routes/activity/components/Activity.js | 41 +++++++++---------- .../components/components/Invoice/Invoice.js | 15 +++++++ .../components/Invoice/Invoice.scss | 0 .../components/components/Invoice/index.js | 3 ++ .../components/components/Payment/Payment.js | 15 +++++++ .../components/Payment/Payment.scss | 0 .../components/components/Payment/index.js | 3 ++ .../components/Transaction/Transaction.js | 15 +++++++ .../components/Transaction/Transaction.scss | 0 .../components/Transaction/index.js | 3 ++ .../activity/containers/ActivityContainer.js | 1 - .../components/Form/components/Pay/Pay.js | 5 ++- 13 files changed, 88 insertions(+), 24 deletions(-) create mode 100644 app/routes/activity/components/components/Invoice/Invoice.js create mode 100644 app/routes/activity/components/components/Invoice/Invoice.scss create mode 100644 app/routes/activity/components/components/Invoice/index.js create mode 100644 app/routes/activity/components/components/Payment/Payment.js create mode 100644 app/routes/activity/components/components/Payment/Payment.scss create mode 100644 app/routes/activity/components/components/Payment/index.js create mode 100644 app/routes/activity/components/components/Transaction/Transaction.js create mode 100644 app/routes/activity/components/components/Transaction/Transaction.scss create mode 100644 app/routes/activity/components/components/Transaction/index.js diff --git a/app/reducers/payment.js b/app/reducers/payment.js index 7a04bd7b..b8dbc445 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -68,7 +68,16 @@ export const payInvoice = paymentRequest => (dispatch) => { // Receive IPC event for successful payment // TODO: Add payment to state, not a total re-fetch -export const paymentSuccessful = () => fetchPayments() +export const paymentSuccessful = () => dispatch => { + // Close the form modal once the payment was succesful + dispatch(setForm({ modalOpen: false })) + + // Refetch payments (TODO: dont do a full refetch, rather append new tx to list) + fetchPayments() + + // Reset the payment form + dispatch(resetForm()) +} // ------------------------------------ diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index 064ac5f1..cd52d7b0 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -1,8 +1,14 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { MdSearch } from 'react-icons/lib/md' +import { FaChain, FaBolt } from 'react-icons/lib/fa' import Payments from './components/Payments' import Invoices from './components/Invoices' + +import Invoice from './components/Invoice' +import Payment from './components/Payment' +import Transaction from './components/Transaction' + import styles from './Activity.scss' class Activity extends Component { @@ -36,7 +42,6 @@ class Activity extends Component { currentTicker, sortedActivity } = this.props - console.log('sortedActivity: ', sortedActivity) if (invoiceLoading || paymentLoading) { return
Loading...
} return (
@@ -69,28 +74,22 @@ class Activity extends Component { Requests -
+
    { - tab === 1 ? - - : - + sortedActivity.map((activity, index) => { + if (activity.hasOwnProperty('block_hash')) { + // activity is an on-chain tx + return + } else if (activity.hasOwnProperty('payment_request')) { + // activity is an LN invoice + return + } else { + // activity is an LN payment + return + } + }) } -
+
) diff --git a/app/routes/activity/components/components/Invoice/Invoice.js b/app/routes/activity/components/components/Invoice/Invoice.js new file mode 100644 index 00000000..89db79aa --- /dev/null +++ b/app/routes/activity/components/components/Invoice/Invoice.js @@ -0,0 +1,15 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './Invoice.scss' + +const Invoice = () => ( +
+ Invoice +
+) + +Invoice.propTypes = { + +} + +export default Invoice diff --git a/app/routes/activity/components/components/Invoice/Invoice.scss b/app/routes/activity/components/components/Invoice/Invoice.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/routes/activity/components/components/Invoice/index.js b/app/routes/activity/components/components/Invoice/index.js new file mode 100644 index 00000000..a72db95c --- /dev/null +++ b/app/routes/activity/components/components/Invoice/index.js @@ -0,0 +1,3 @@ +import Invoice from './Invoice' + +export default Invoice \ No newline at end of file diff --git a/app/routes/activity/components/components/Payment/Payment.js b/app/routes/activity/components/components/Payment/Payment.js new file mode 100644 index 00000000..833b51f6 --- /dev/null +++ b/app/routes/activity/components/components/Payment/Payment.js @@ -0,0 +1,15 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './Payment.scss' + +const Payment = () => ( +
+ Payment +
+) + +Payment.propTypes = { + +} + +export default Payment diff --git a/app/routes/activity/components/components/Payment/Payment.scss b/app/routes/activity/components/components/Payment/Payment.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/routes/activity/components/components/Payment/index.js b/app/routes/activity/components/components/Payment/index.js new file mode 100644 index 00000000..3f7e6951 --- /dev/null +++ b/app/routes/activity/components/components/Payment/index.js @@ -0,0 +1,3 @@ +import Payment from './Payment' + +export default Payment diff --git a/app/routes/activity/components/components/Transaction/Transaction.js b/app/routes/activity/components/components/Transaction/Transaction.js new file mode 100644 index 00000000..5e1fb5eb --- /dev/null +++ b/app/routes/activity/components/components/Transaction/Transaction.js @@ -0,0 +1,15 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './Transaction.scss' + +const Transaction = () => ( +
+ transaction +
+) + +Transaction.propTypes = { + +} + +export default Transaction diff --git a/app/routes/activity/components/components/Transaction/Transaction.scss b/app/routes/activity/components/components/Transaction/Transaction.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/routes/activity/components/components/Transaction/index.js b/app/routes/activity/components/components/Transaction/index.js new file mode 100644 index 00000000..7fc5e311 --- /dev/null +++ b/app/routes/activity/components/components/Transaction/index.js @@ -0,0 +1,3 @@ +import Transaction from './Transaction' + +export default Transaction diff --git a/app/routes/activity/containers/ActivityContainer.js b/app/routes/activity/containers/ActivityContainer.js index 35658ed7..c860ea0c 100644 --- a/app/routes/activity/containers/ActivityContainer.js +++ b/app/routes/activity/containers/ActivityContainer.js @@ -24,7 +24,6 @@ const mapDispatchToProps = { searchInvoices } -console.log('activitySelectors: ', activitySelectors) const mapStateToProps = state => ({ activity: state.activity, diff --git a/app/routes/app/components/components/Form/components/Pay/Pay.js b/app/routes/app/components/components/Form/components/Pay/Pay.js index 38c33f12..dbf9da89 100644 --- a/app/routes/app/components/components/Form/components/Pay/Pay.js +++ b/app/routes/app/components/components/Form/components/Pay/Pay.js @@ -128,7 +128,10 @@ class Pay extends Component { Pay.propTypes = { sendingTransaction: PropTypes.bool.isRequired, - invoiceAmount: PropTypes.string.isRequired, + invoiceAmount: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]).isRequired, onchainAmount: PropTypes.string.isRequired, setOnchainAmount: PropTypes.func.isRequired, payment_request: PropTypes.string.isRequired, From 350ce99a5830f700ee62ad8e48ada16e4f5181c7 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 19 Sep 2017 23:19:44 -0500 Subject: [PATCH 05/21] feature(transaction): style transaction activity in activities list --- app/routes/activity/components/Activity.js | 32 +++-- app/routes/activity/components/Activity.scss | 4 +- .../components/Transaction/Transaction.js | 54 ++++++++- .../components/Transaction/Transaction.scss | 111 ++++++++++++++++++ app/tooltip.scss | 2 +- 5 files changed, 186 insertions(+), 17 deletions(-) diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index cd52d7b0..0ce06382 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -17,6 +17,8 @@ class Activity extends Component { this.state = { tab: 1 } + + this.renderActivity = this.renderActivity.bind(this) } componentWillMount() { @@ -27,6 +29,21 @@ class Activity extends Component { fetchTransactions() } + renderActivity(activity) { + const { ticker, currentTicker } = this.props + + if (activity.hasOwnProperty('block_hash')) { + // activity is an on-chain tx + return + } else if (activity.hasOwnProperty('payment_request')) { + // activity is an LN invoice + return + } else { + // activity is an LN payment + return + } + } + render() { const { tab } = this.state const { @@ -77,16 +94,11 @@ class Activity extends Component {
    { sortedActivity.map((activity, index) => { - if (activity.hasOwnProperty('block_hash')) { - // activity is an on-chain tx - return - } else if (activity.hasOwnProperty('payment_request')) { - // activity is an LN invoice - return - } else { - // activity is an LN payment - return - } + return ( +
  • + {this.renderActivity(activity)} +
  • + ) }) }
diff --git a/app/routes/activity/components/Activity.scss b/app/routes/activity/components/Activity.scss index 8846d58f..53eddf9e 100644 --- a/app/routes/activity/components/Activity.scss +++ b/app/routes/activity/components/Activity.scss @@ -76,9 +76,7 @@ } .activity { - padding: 35px 10px; - border-bottom: 1px solid $grey; - font-size: 14px; + padding: 0 100px; .left, .center, .right { display: inline-block; diff --git a/app/routes/activity/components/components/Transaction/Transaction.js b/app/routes/activity/components/components/Transaction/Transaction.js index 5e1fb5eb..2a16f2dc 100644 --- a/app/routes/activity/components/components/Transaction/Transaction.js +++ b/app/routes/activity/components/components/Transaction/Transaction.js @@ -1,10 +1,58 @@ import React from 'react' import PropTypes from 'prop-types' +import Moment from 'react-moment' +import 'moment-timezone' +import { FaChain } from 'react-icons/lib/fa' +import { btc } from '../../../../../utils' +import CurrencyIcon from '../../../../../components/CurrencyIcon' import styles from './Transaction.scss' -const Transaction = () => ( -
- transaction +const Transaction = ({ transaction, ticker, currentTicker }) => ( +
+ + + +
+
+ {transaction.tx_hash} +
+
+ {transaction.num_confirmations} confirmations +
+
+
+ {transaction.time_stamp * 1000} +
+
+
+ +
+
+ + { + ticker.currency === 'usd' ? + btc.satoshisToUsd(transaction.amount, currentTicker.price_usd) + : + btc.satoshisToBtc(transaction.amount) + } + + + { + transaction.amount < 0 ? + ticker.currency === 'usd' ? + btc.satoshisToUsd(transaction.total_fees, currentTicker.price_usd) + : + btc.satoshisToBtc(transaction.total_fees) + : + null + } + +
+
) diff --git a/app/routes/activity/components/components/Transaction/Transaction.scss b/app/routes/activity/components/components/Transaction/Transaction.scss index e69de29b..5bf06196 100644 --- a/app/routes/activity/components/components/Transaction/Transaction.scss +++ b/app/routes/activity/components/components/Transaction/Transaction.scss @@ -0,0 +1,111 @@ +@import '../../../../../variables.scss'; + +.container { + display: flex; + flex-direction: row; + cursor: pointer; + max-width: 960px; + margin: 0 auto; + height: 76px; + align-items: center; + border-bottom: 1px solid $grey; + font-size: 14px; + transition: background-color .1s linear; + transition-delay: .1s; + color: $darkestgrey; + position: relative; +} + +.icon { + display: block; + margin-right: 20px; + flex: none; + position: relative; + width: 36px; + height: 36px; + border: 1px solid $darkestgrey; + border-radius: 50%; + + svg { + color: $main; + font-size: 16px; + vertical-align: middle; + display: flex; + top: 0; + left: 50%; + height: 100%; + margin: 0 auto; + } +} + +.data { + display: flex; + flex-direction: row; + flex: 6 0; + + .title { + flex: 8 0; + } + + .subtitle { + padding-left: 20px; + flex: 2 0; + } +} + +.subtitle, .date { + text-align: center; +} + +.date { + padding-left: 20px; + flex: 1 0; +} + +.amount { + flex: 1 0; + padding-left: 20px; + + &.negative { + font-weight: 200; + } + + &.positive { + color: $main; + font-weight: 500; + } + + section { + display: inline-block; + vertical-align: top; + text-align: right; + font-size: 0; + margin: 0; + padding: 0; + + &:nth-child(1) { + width: 20%; + } + + &:nth-child(2) { + width: 80%; + } + } + + svg { + font-size: 20px; + } + + span { + display: block; + + &:nth-child(1) { + font-size: 14px; + } + + &:nth-child(2) { + font-size: 10px; + } + } +} + diff --git a/app/tooltip.scss b/app/tooltip.scss index 65eb544c..6ca18e7a 100644 --- a/app/tooltip.scss +++ b/app/tooltip.scss @@ -130,4 +130,4 @@ .hint--left:hover:before { -webkit-transform: translateX(-8px); transform: translateX(-8px); -} \ No newline at end of file +} From b77c1f5b7375b0ce3400352a07038d488e666738 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 20 Sep 2017 13:05:51 -0500 Subject: [PATCH 06/21] feature(activity): style LN payment and request components --- app/routes/activity/components/Activity.js | 5 +- .../components/components/Activity.scss | 117 ++++++++++++++++++ .../components/components/Invoice/Invoice.js | 60 ++++++++- .../components/components/Payment/Payment.js | 59 ++++++++- .../components/Transaction/Transaction.js | 12 +- 5 files changed, 242 insertions(+), 11 deletions(-) create mode 100644 app/routes/activity/components/components/Activity.scss diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index 0ce06382..37a061b6 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -37,10 +37,11 @@ class Activity extends Component { return } else if (activity.hasOwnProperty('payment_request')) { // activity is an LN invoice - return + console.log('activity: ', activity) + return } else { // activity is an LN payment - return + return } } diff --git a/app/routes/activity/components/components/Activity.scss b/app/routes/activity/components/components/Activity.scss new file mode 100644 index 00000000..de728313 --- /dev/null +++ b/app/routes/activity/components/components/Activity.scss @@ -0,0 +1,117 @@ +@import '../../../../variables.scss'; + +.container { + display: flex; + flex-direction: row; + cursor: pointer; + max-width: 960px; + margin: 0 auto; + height: 76px; + align-items: center; + border-bottom: 1px solid $grey; + font-size: 14px; + transition: background-color .1s linear; + transition-delay: .1s; + color: $darkestgrey; + position: relative; +} + +.label { + position: absolute; + top: 0; + left: -25%; +} + +.icon { + display: block; + margin-right: 20px; + flex: none; + position: relative; + width: 36px; + height: 36px; + border: 1px solid $darkestgrey; + border-radius: 50%; + + svg { + color: $main; + font-size: 16px; + vertical-align: middle; + display: flex; + top: 0; + left: 50%; + height: 100%; + margin: 0 auto; + } +} + +.data { + display: flex; + flex-direction: row; + flex: 6 0; + + .title { + flex: 8 0; + } + + .subtitle { + padding-left: 20px; + flex: 2 0; + } +} + +.subtitle, .date { + text-align: center; +} + +.date { + padding-left: 20px; + flex: 1 0; +} + +.amount { + flex: 1 0; + padding-left: 20px; + + &.negative { + font-weight: 200; + } + + &.positive { + color: $main; + font-weight: 500; + } + + section { + display: inline-block; + vertical-align: top; + text-align: right; + font-size: 0; + margin: 0; + padding: 0; + + &:nth-child(1) { + width: 20%; + } + + &:nth-child(2) { + width: 80%; + } + } + + svg { + font-size: 20px; + } + + span { + display: block; + + &:nth-child(1) { + font-size: 14px; + } + + &:nth-child(2) { + font-size: 10px; + } + } +} + diff --git a/app/routes/activity/components/components/Invoice/Invoice.js b/app/routes/activity/components/components/Invoice/Invoice.js index 89db79aa..ac1b2000 100644 --- a/app/routes/activity/components/components/Invoice/Invoice.js +++ b/app/routes/activity/components/components/Invoice/Invoice.js @@ -1,10 +1,62 @@ import React from 'react' import PropTypes from 'prop-types' -import styles from './Invoice.scss' +import Moment from 'react-moment' +import 'moment-timezone' +import { FaBolt } from 'react-icons/lib/fa' +import { btc } from '../../../../../utils' +import CurrencyIcon from '../../../../../components/CurrencyIcon' +import styles from '../Activity.scss' -const Invoice = () => ( -
- Invoice +const Invoice = ({ invoice, ticker, currentTicker }) => ( +
+ + + +
+
+ {invoice.r_hash.toString('hex')} +
+
+ {invoice.memo} +
+
+
+ + { + invoice.settled ? + invoice.settle_date * 1000 + : + invoice.creation_date * 1000 + } + +
+
+
+ +
+
+ + { + ticker.currency === 'usd' ? + btc.satoshisToUsd(invoice.value, currentTicker.price_usd) + : + btc.satoshisToBtc(invoice.value) + } + + + { + ticker.currency === 'usd' ? + btc.satoshisToUsd(invoice.fee, currentTicker.price_usd) + : + btc.satoshisToBtc(invoice.fee) + } + +
+
) diff --git a/app/routes/activity/components/components/Payment/Payment.js b/app/routes/activity/components/components/Payment/Payment.js index 833b51f6..e131b91e 100644 --- a/app/routes/activity/components/components/Payment/Payment.js +++ b/app/routes/activity/components/components/Payment/Payment.js @@ -1,10 +1,61 @@ import React from 'react' import PropTypes from 'prop-types' -import styles from './Payment.scss' +import Moment from 'react-moment' +import 'moment-timezone' +import { FaBolt } from 'react-icons/lib/fa' +import { btc } from '../../../../../utils' +import CurrencyIcon from '../../../../../components/CurrencyIcon' +import styles from '../Activity.scss' -const Payment = () => ( -
- Payment +const Payment = ({ payment, ticker, currentTicker }) => ( +
+ + + +
+
+ {payment.payment_hash} +
+
+ { + payment.path.length > 1 ? + `${payment.path.length} hops` + : + 'Directly routed' + } +
+
+
+ {payment.creation_date * 1000} +
+
+
+ +
+
+ + - + { + ticker.currency === 'usd' ? + btc.satoshisToUsd(payment.value, currentTicker.price_usd) + : + btc.satoshisToBtc(payment.value) + } + + + { + ticker.currency === 'usd' ? + btc.satoshisToUsd(payment.fee, currentTicker.price_usd) + : + btc.satoshisToBtc(payment.fee) + } + +
+
) diff --git a/app/routes/activity/components/components/Transaction/Transaction.js b/app/routes/activity/components/components/Transaction/Transaction.js index 2a16f2dc..f8f42f3e 100644 --- a/app/routes/activity/components/components/Transaction/Transaction.js +++ b/app/routes/activity/components/components/Transaction/Transaction.js @@ -5,10 +5,20 @@ import 'moment-timezone' import { FaChain } from 'react-icons/lib/fa' import { btc } from '../../../../../utils' import CurrencyIcon from '../../../../../components/CurrencyIcon' -import styles from './Transaction.scss' +import styles from '../Activity.scss' const Transaction = ({ transaction, ticker, currentTicker }) => (
+
+

+ { + transaction.amount < 0 ? + 'Sent' + : + 'Received' + } +

+
From 91eec1d1630730ad089f0bd18e6ca15f426e5d4d Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 20 Sep 2017 14:03:50 -0500 Subject: [PATCH 07/21] fix(label): redesign activity label --- .../components/components/Activity.scss | 23 +++++++++++-------- .../components/components/Invoice/Invoice.js | 19 ++++++++++----- .../components/components/Payment/Payment.js | 19 +++++++-------- .../components/Transaction/Transaction.js | 9 +++----- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/app/routes/activity/components/components/Activity.scss b/app/routes/activity/components/components/Activity.scss index de728313..e558c94a 100644 --- a/app/routes/activity/components/components/Activity.scss +++ b/app/routes/activity/components/components/Activity.scss @@ -17,14 +17,24 @@ } .label { - position: absolute; - top: 0; - left: -25%; + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-items: center; + margin-right: 20px; + width: 65px; + + h3 { + text-transform: uppercase; + letter-spacing: 2px; + font-size: 10px; + font-weight: 500; + margin-top: 10px; + } } .icon { display: block; - margin-right: 20px; flex: none; position: relative; width: 36px; @@ -52,11 +62,6 @@ .title { flex: 8 0; } - - .subtitle { - padding-left: 20px; - flex: 2 0; - } } .subtitle, .date { diff --git a/app/routes/activity/components/components/Invoice/Invoice.js b/app/routes/activity/components/components/Invoice/Invoice.js index ac1b2000..fc03e83b 100644 --- a/app/routes/activity/components/components/Invoice/Invoice.js +++ b/app/routes/activity/components/components/Invoice/Invoice.js @@ -9,16 +9,23 @@ import styles from '../Activity.scss' const Invoice = ({ invoice, ticker, currentTicker }) => (
- - - +
+ + + +

+ { + invoice.settled ? + 'Received' + : + 'Requested' + } +

+
{invoice.r_hash.toString('hex')}
-
- {invoice.memo} -
diff --git a/app/routes/activity/components/components/Payment/Payment.js b/app/routes/activity/components/components/Payment/Payment.js index e131b91e..37da8145 100644 --- a/app/routes/activity/components/components/Payment/Payment.js +++ b/app/routes/activity/components/components/Payment/Payment.js @@ -9,21 +9,18 @@ import styles from '../Activity.scss' const Payment = ({ payment, ticker, currentTicker }) => (
- - - +
+ + + +

+ Sent +

+
{payment.payment_hash}
-
- { - payment.path.length > 1 ? - `${payment.path.length} hops` - : - 'Directly routed' - } -
{payment.creation_date * 1000} diff --git a/app/routes/activity/components/components/Transaction/Transaction.js b/app/routes/activity/components/components/Transaction/Transaction.js index f8f42f3e..8b3bb08f 100644 --- a/app/routes/activity/components/components/Transaction/Transaction.js +++ b/app/routes/activity/components/components/Transaction/Transaction.js @@ -10,6 +10,9 @@ import styles from '../Activity.scss' const Transaction = ({ transaction, ticker, currentTicker }) => (
+ + +

{ transaction.amount < 0 ? @@ -19,16 +22,10 @@ const Transaction = ({ transaction, ticker, currentTicker }) => ( }

- - -
{transaction.tx_hash}
-
- {transaction.num_confirmations} confirmations -
{transaction.time_stamp * 1000} From 6c1eb42d3638767bbb73f84be74918ed27cc223c Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 20 Sep 2017 14:21:01 -0500 Subject: [PATCH 08/21] fix(header): redesign activity header --- app/routes/activity/components/Activity.js | 15 ++-------- app/routes/activity/components/Activity.scss | 30 ++++++------------- .../components/components/Invoice/Invoice.js | 7 +---- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index 37a061b6..3ff58af9 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -71,7 +71,7 @@ class Activity extends Component { value={tab === 1 ? '' : invoicesSearchText} onChange={event => (tab === 1 ? null : searchInvoices(event.target.value))} className={`${styles.text} ${styles.input}`} - placeholder={tab === 1 ? 'Search transactions by amount, public key, channel' : 'Search requests by memo'} + placeholder={tab === 1 ? 'Search by amount, hash, memo, etc' : 'Search requests by memo'} type='text' id='invoiceSearch' /> @@ -79,18 +79,7 @@ class Activity extends Component {
- this.setState({ tab: 1 })} - > - Payments - - this.setState({ tab: 2 })} - > - Requests - +

Activity

    { diff --git a/app/routes/activity/components/Activity.scss b/app/routes/activity/components/Activity.scss index 53eddf9e..569b95fc 100644 --- a/app/routes/activity/components/Activity.scss +++ b/app/routes/activity/components/Activity.scss @@ -34,31 +34,19 @@ background: $lightgrey; .header { - width: 75%; + padding: 60px 0 20px 0; margin: 0 auto; - .title { - display: inline-block; - margin: 60px 0 20px 0; - padding: 5px 10px; - background: $lightgrey; - color: $darkestgrey; + h2 { + margin-left: auto; + margin-right: auto; + padding-left: 100px; + padding-right: 100px; text-transform: uppercase; + letter-spacing: 1.5px; + color: $darkestgrey; font-size: 14px; - font-weight: 400; - letter-spacing: 1.6px; - cursor: pointer; - transition: all 0.5s; - - &:first-child { - border-right: 1px solid $darkestgrey; - } - - - &.active { - color: $main; - font-weight: bold; - } + font-weight: 400; } } } diff --git a/app/routes/activity/components/components/Invoice/Invoice.js b/app/routes/activity/components/components/Invoice/Invoice.js index fc03e83b..e634ac90 100644 --- a/app/routes/activity/components/components/Invoice/Invoice.js +++ b/app/routes/activity/components/components/Invoice/Invoice.js @@ -29,12 +29,7 @@ const Invoice = ({ invoice, ticker, currentTicker }) => (
- { - invoice.settled ? - invoice.settle_date * 1000 - : - invoice.creation_date * 1000 - } + {invoice.creation_date * 1000}
From 430d016e785f1d8c9e1f385795c2cba87ed66dd9 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 20 Sep 2017 15:19:11 -0500 Subject: [PATCH 09/21] fix(styles): remove unneeded padding --- app/routes/activity/components/Activity.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/routes/activity/components/Activity.scss b/app/routes/activity/components/Activity.scss index 569b95fc..6b28b1dd 100644 --- a/app/routes/activity/components/Activity.scss +++ b/app/routes/activity/components/Activity.scss @@ -53,8 +53,6 @@ .activityContainer { background: $white; - padding: 20px 0; - } .activityList { @@ -66,6 +64,12 @@ .activity { padding: 0 100px; + &:hover { + background-color: #f0f0f0; + transition-delay: 0s; + outline: $grey solid 1px; + } + .left, .center, .right { display: inline-block; vertical-align: top; From dd5ef86dc93d8a20cc2b9b86c30c818ea1af0ead Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 20 Sep 2017 16:13:30 -0500 Subject: [PATCH 10/21] feature(activity modal): add activity reducer and basic activity modal functionality --- app/reducers/activity.js | 50 +++++++++++++++++++ app/reducers/index.js | 4 +- app/routes/activity/components/Activity.js | 19 ++++--- .../components/components/Invoice/Invoice.js | 4 +- .../components/{ => Modal}/Modal.js | 16 +++--- .../components/components/Modal/index.js | 3 ++ .../components/components/Payment/Payment.js | 4 +- .../components/Transaction/Transaction.js | 4 +- .../activity/containers/ActivityContainer.js | 5 +- 9 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 app/reducers/activity.js rename app/routes/activity/components/components/{ => Modal}/Modal.js (70%) create mode 100644 app/routes/activity/components/components/Modal/index.js diff --git a/app/reducers/activity.js b/app/reducers/activity.js new file mode 100644 index 00000000..e1af749c --- /dev/null +++ b/app/reducers/activity.js @@ -0,0 +1,50 @@ +// ------------------------------------ +// Initial State +// ------------------------------------ +const initialState = { + filter: 'ALL_ACTIVITY', + modal: { + modalType: null, + modalProps: {} + } +} + +// ------------------------------------ +// Constants +// ------------------------------------ +export const SHOW_ACTIVITY_MODAL = 'SHOW_ACTIVITY_MODAL' +export const HIDE_ACTIVITY_MODAL = 'HIDE_ACTIVITY_MODAL' + +// ------------------------------------ +// Actions +// ------------------------------------ +export function showActivityModal(modalType, modalProps) { + return { + type: SHOW_ACTIVITY_MODAL, + modalType, + modalProps + } +} + +export function hideActivityModal() { + return { + type: HIDE_ACTIVITY_MODAL + } +} + +// ------------------------------------ +// Action Handlers +// ------------------------------------ +const ACTION_HANDLERS = { + [SHOW_ACTIVITY_MODAL]: (state, { modalType, modalProps }) => ({ ...state, modal: { modalType, modalProps } }), + [HIDE_ACTIVITY_MODAL]: (state) => ({ ...state, modal: { modalType: null, modalProps: {} } }) +} + +// ------------------------------------ +// Reducer +// ------------------------------------ +export default function activityReducer(state = initialState, action) { + const handler = ACTION_HANDLERS[action.type] + + return handler ? handler(state, action) : state +} diff --git a/app/reducers/index.js b/app/reducers/index.js index 75b0597e..4c906733 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -12,6 +12,7 @@ import invoice from './invoice' import modal from './modal' import address from './address' import transaction from './transaction' +import activity from './activity' const rootReducer = combineReducers({ router, @@ -25,7 +26,8 @@ const rootReducer = combineReducers({ invoice, modal, address, - transaction + transaction, + activity }) export default rootReducer diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index 3ff58af9..11602edc 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -9,6 +9,8 @@ import Invoice from './components/Invoice' import Payment from './components/Payment' import Transaction from './components/Transaction' +import Modal from './components/Modal' + import styles from './Activity.scss' class Activity extends Component { @@ -30,18 +32,17 @@ class Activity extends Component { } renderActivity(activity) { - const { ticker, currentTicker } = this.props + const { ticker, currentTicker, showActivityModal } = this.props if (activity.hasOwnProperty('block_hash')) { // activity is an on-chain tx - return + return } else if (activity.hasOwnProperty('payment_request')) { // activity is an LN invoice - console.log('activity: ', activity) - return + return } else { // activity is an LN payment - return + return } } @@ -58,11 +59,17 @@ class Activity extends Component { paymentModalOpen, invoiceModalOpen, currentTicker, - sortedActivity + sortedActivity, + activity: { modal }, + hideActivityModal } = this.props + if (invoiceLoading || paymentLoading) { return
Loading...
} + return (
+ +