From 6e7e4e1cacc41cc504e2a82ae0d8d08dead07427 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 3 Oct 2017 12:52:29 -0500 Subject: [PATCH 01/15] feature(global-error): set up global error component --- app/components/GlobalError/GlobalError.js | 16 ++++++++++++++++ app/components/GlobalError/GlobalError.scss | 0 app/components/GlobalError/index.js | 3 +++ app/routes/app/components/App.js | 2 ++ 4 files changed, 21 insertions(+) create mode 100644 app/components/GlobalError/GlobalError.js create mode 100644 app/components/GlobalError/GlobalError.scss create mode 100644 app/components/GlobalError/index.js diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js new file mode 100644 index 00000000..a5cb0fec --- /dev/null +++ b/app/components/GlobalError/GlobalError.js @@ -0,0 +1,16 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './GlobalError' + +const GlobalError = ({ error }) => { + console.log('error: ', error) + return ( +
+ yo global error mf +
+ ) +} + +GlobalError.propTypes = {} + +export default GlobalError diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/components/GlobalError/index.js b/app/components/GlobalError/index.js new file mode 100644 index 00000000..41eb98ac --- /dev/null +++ b/app/components/GlobalError/index.js @@ -0,0 +1,3 @@ +import GlobalError from './GlobalError' + +export default GlobalError \ No newline at end of file diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index b1db6815..5c8e5299 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -1,5 +1,6 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' +import GlobalError from 'components/GlobalError' import LoadingBolt from 'components/LoadingBolt' import Form from 'components/Form' import ModalRoot from 'components/ModalRoot' @@ -37,6 +38,7 @@ class App extends Component { return (
+ Date: Tue, 3 Oct 2017 14:24:45 -0500 Subject: [PATCH 02/15] feature(global-errors): hook up global errors reducer to component and set error on transaction fail --- app/components/GlobalError/GlobalError.js | 7 ++-- app/components/GlobalError/GlobalError.scss | 24 +++++++++++ app/lnd/methods/index.js | 5 ++- app/reducers/error.js | 45 +++++++++++++++++++++ app/reducers/index.js | 4 +- app/reducers/transaction.js | 4 +- app/routes/app/components/App.js | 4 +- app/routes/app/containers/AppContainer.js | 2 + 8 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 app/reducers/error.js diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index a5cb0fec..63a4f0a7 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -1,12 +1,13 @@ import React from 'react' import PropTypes from 'prop-types' -import styles from './GlobalError' +import styles from './GlobalError.scss' const GlobalError = ({ error }) => { console.log('error: ', error) + if (!error) { return null } return ( -
- yo global error mf +
+

{error}

) } diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss index e69de29b..4e0dad23 100644 --- a/app/components/GlobalError/GlobalError.scss +++ b/app/components/GlobalError/GlobalError.scss @@ -0,0 +1,24 @@ +@import '../../variables.scss'; + +.container { + position: absolute; + z-index: 1001; + background: $red; + color: $white; + width: 100%; + text-align: center; + padding: 20px; + // height: 0; + transition: all 0.25s ease; + + &.active { + height: 100%; + padding: 20px; + } + + h2 { + font-size: 20px; + letter-spacing: 1.5px; + font-weight: bold; + } +} \ No newline at end of file diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index 073ef4ab..e15ceaa4 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -114,7 +114,10 @@ export default function (lnd, event, msg, data) { // { amount, addr } = data walletController.sendCoins(lnd, data) .then(({ txid }) => event.sender.send('transactionSuccessful', { amount: data.amount, addr: data.addr, txid })) - .catch(error => event.sender.send('transactionError', { error })) + .catch(error => { + console.log('error: ', error) + event.sender.send('transactionError', { error: error.toString() }) + }) break case 'openChannel': // Response is empty. Streaming updates on channel status and updates diff --git a/app/reducers/error.js b/app/reducers/error.js new file mode 100644 index 00000000..8f3404fd --- /dev/null +++ b/app/reducers/error.js @@ -0,0 +1,45 @@ +// ------------------------------------ +// Initial State +// ------------------------------------ +const initialState = { + error: null +} + +// ------------------------------------ +// Constants +// ------------------------------------ +export const SET_ERROR = 'SET_ERROR' +export const CLEAR_ERROR = 'CLEAR_ERROR' + +// ------------------------------------ +// Actions +// ------------------------------------ +export function setError(error) { + return { + type: SET_ERROR, + error + } +} + +export function clearError() { + return { + type: CLEAR_ERROR + } +} + +// ------------------------------------ +// Action Handlers +// ------------------------------------ +const ACTION_HANDLERS = { + [SET_ERROR]: (state, { error }) => ({ ...state, error }), + [CLEAR_ERROR]: () => (initialState) +} + +// ------------------------------------ +// Reducer +// ------------------------------------ +export default function errorReducer(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 86eda032..08da873c 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -17,6 +17,7 @@ import modal from './modal' import address from './address' import transaction from './transaction' import activity from './activity' +import error from './error' const rootReducer = combineReducers({ router, @@ -35,7 +36,8 @@ const rootReducer = combineReducers({ modal, address, transaction, - activity + activity, + error }) export default rootReducer diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 949df4ca..5785aafd 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -4,6 +4,7 @@ import { btc, usd } from '../utils' import { setFormType } from './form' import { resetPayForm } from './payform' import { showModal } from './modal' +import { setError } from './error' // ------------------------------------ // Constants @@ -64,8 +65,9 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc dispatch(resetPayForm()) } -export const transactionError = () => (dispatch) => { +export const transactionError = (event, { error }) => (dispatch) => { dispatch({ type: TRANSACTION_FAILED }) + dispatch(setError(error)) } // Listener for when a new transaction is pushed from the subscriber diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 5c8e5299..8162dde3 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -31,6 +31,8 @@ class App extends Component { formProps, closeForm, + error: { error }, + children } = this.props @@ -38,7 +40,7 @@ class App extends Component { return (
- + ({ invoice: state.invoice, modal: state.modal, + error: state.error, + currentTicker: tickerSelectors.currentTicker(state), isOnchain: payFormSelectors.isOnchain(state), isLn: payFormSelectors.isLn(state), From 92da36a7e1be2584bb2918de454dd150f3bdb46b Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 4 Oct 2017 11:49:30 -0500 Subject: [PATCH 03/15] fix(channels): force close channels --- app/components/GlobalError/GlobalError.js | 5 +++-- app/lnd/methods/channelController.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index 63a4f0a7..a0e8b2ab 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types' import styles from './GlobalError.scss' const GlobalError = ({ error }) => { - console.log('error: ', error) if (!error) { return null } return (
@@ -12,6 +11,8 @@ const GlobalError = ({ error }) => { ) } -GlobalError.propTypes = {} +GlobalError.propTypes = { + error: PropTypes.string +} export default GlobalError diff --git a/app/lnd/methods/channelController.js b/app/lnd/methods/channelController.js index a508904b..dd328ad0 100644 --- a/app/lnd/methods/channelController.js +++ b/app/lnd/methods/channelController.js @@ -72,7 +72,8 @@ export function closeChannel(lnd, event, payload) { channel_point: { funding_txid: BufferUtil.hexToBuffer(tx), output_index: Number(payload.channel_point.output_index) - } + }, + force: true } return new Promise((resolve, reject) => From a2e4e0ad7db1c56d88a477c572eb485f7c027192 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 4 Oct 2017 16:12:25 -0500 Subject: [PATCH 04/15] feature(globalerror): clear error --- app/components/GlobalError/GlobalError.js | 19 +++++++++------ app/components/GlobalError/GlobalError.scss | 26 ++++++++++++++------- app/routes/app/components/App.js | 3 ++- app/routes/app/containers/AppContainer.js | 6 ++++- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index a0e8b2ab..75f09a1e 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -1,18 +1,23 @@ import React from 'react' import PropTypes from 'prop-types' +import { MdClose } from 'react-icons/lib/md' import styles from './GlobalError.scss' -const GlobalError = ({ error }) => { - if (!error) { return null } - return ( -
+const GlobalError = ({ error, clearError }) => ( +
+
+
+ +

{error}

- ) -} +
+) + GlobalError.propTypes = { - error: PropTypes.string + error: PropTypes.string, + clearError: PropTypes.func.isRequired } export default GlobalError diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss index 4e0dad23..5486c7fc 100644 --- a/app/components/GlobalError/GlobalError.scss +++ b/app/components/GlobalError/GlobalError.scss @@ -8,17 +8,27 @@ width: 100%; text-align: center; padding: 20px; - // height: 0; transition: all 0.25s ease; - &.active { - height: 100%; - padding: 20px; + &.closed { + max-height: 0; + padding: 0; } - h2 { - font-size: 20px; - letter-spacing: 1.5px; - font-weight: bold; + .content { + position: relative; + + .close { + position: absolute; + top: calc(50% - 8px); + right: 10%; + cursor: pointer; + } + + h2 { + font-size: 20px; + letter-spacing: 1.5px; + font-weight: bold; + } } } \ No newline at end of file diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 8162dde3..4095cbd9 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -32,6 +32,7 @@ class App extends Component { closeForm, error: { error }, + clearError, children } = this.props @@ -40,7 +41,7 @@ class App extends Component { return (
- + ({ From 46b03abc5a79d74487165abf8656e69da020f3bc Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 4 Oct 2017 18:35:58 -0500 Subject: [PATCH 05/15] fix(payform): input styles --- app/components/Form/PayForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/Form/PayForm.js b/app/components/Form/PayForm.js index 3d93da5f..5f84cc71 100644 --- a/app/components/Form/PayForm.js +++ b/app/components/Form/PayForm.js @@ -63,7 +63,7 @@ class PayForm extends Component { isLn ? { width: '75%', fontSize: '85px' } : - { width: `${amount.length > 1 ? (amount.length * 15) - 5 : 25}%`, fontSize: `${190 - (amount.length ** 2)}px` } + { width: `${amount.length > 1 ? (amount.length * 20) - 5 : 25}%`, fontSize: `${190 - (amount.length ** 2)}px` } } value={currentAmount} onChange={event => setPayAmount(event.target.value)} From 2ef2f105a24ba34ad005c9f4cd19ac5310af4159 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 25 Oct 2017 12:09:32 -0500 Subject: [PATCH 06/15] resolving merge conflicts --- app/components/GlobalError/GlobalError.js | 16 ++++++++++++++++ app/components/GlobalError/GlobalError.scss | 0 app/components/GlobalError/index.js | 3 +++ app/routes/app/components/App.js | 2 ++ resources/bin/win32/lnd.exe | Bin 26313835 -> 26313820 bytes 5 files changed, 21 insertions(+) create mode 100644 app/components/GlobalError/GlobalError.js create mode 100644 app/components/GlobalError/GlobalError.scss create mode 100644 app/components/GlobalError/index.js diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js new file mode 100644 index 00000000..a5cb0fec --- /dev/null +++ b/app/components/GlobalError/GlobalError.js @@ -0,0 +1,16 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styles from './GlobalError' + +const GlobalError = ({ error }) => { + console.log('error: ', error) + return ( +
+ yo global error mf +
+ ) +} + +GlobalError.propTypes = {} + +export default GlobalError diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/components/GlobalError/index.js b/app/components/GlobalError/index.js new file mode 100644 index 00000000..41eb98ac --- /dev/null +++ b/app/components/GlobalError/index.js @@ -0,0 +1,3 @@ +import GlobalError from './GlobalError' + +export default GlobalError \ No newline at end of file diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 6d135d0b..e48d0736 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -1,6 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import LndSyncing from 'components/LndSyncing' +import GlobalError from 'components/GlobalError' import LoadingBolt from 'components/LoadingBolt' import Form from 'components/Form' import ModalRoot from 'components/ModalRoot' @@ -57,6 +58,7 @@ class App extends Component { return (
+ zJxPRCA{9Mna9Vg133+-FE84)9jh@zsHC@x|}2~kp%5~W2MQC5@_aiYAa zAmT+uQAt!5RYX-$O;i^(L`_jk)E0F_T~SZe7YU+)Xeb(q#-fQx6ir1l(Ok3;Ek!HQ zTC@>uMUrSI+KUdNqv#|$i)4`^x`?i#o9Hfjh@K)<^b);AAJJFz6aB>iF;EN=gT)Xr zR16ct#RxG{q=|GfN{kj6VvNWXW5qZzUQ7@Z#UwFVOc7JXG%;Pw5HrOrF=rpJN;(@&PCGFwCX$nWBJ^_TmC(u1tD#fTob=NN8b%U09ZjHM zV@4$ZR6*#qX#T0!Gx|pgzccJe?KZJe^{S^8+^h@a1&~MSylfReSdvJJWVfScGW?@nV&$viIR$=IJ=#S8! zp}#_ZhyDru8~Sf|K~_v|$P_U}O)*p4#F`SOq$y=en=+=XDQDtLc~il}n~J8Ascfp4 zs-~K$ZfcmCrk1H~>X^Ewo~dsVOas%&)W~50o z>1LD}Z8FRllWE49ab~=kU?!SLX0n-LrkZJHx|v~SnptMH`Tqsxc+EBQ%zU%JEHsPE zVzb07HOtI$v%;)2m{lg*tTt=RTC>iqHyg}Gv&n2WTg+Co&B$yw5wpYWG`q}hlVkRn Ry(ZV}i#b-1wLd1W_7xCE?6?2` delta 1664 zcmW;KWq1};7{>AIh0zQc4Wqkz!03k28;sEnqx(Nb=gmeA6rGBqsECb)uL%aC2$&cs zC^m{t%-M2oKKy^zdCv8GI@dX$eWK*$&~75J8xRpuKok@)qL3&oiio13m?$nvh>{{! zloF*y84)MSigKd7s30neN}{r;BC3jbQB71AHAGEOOVk#1L|su&)E5mzL(xby7EMG` z(M&WKEksMvO0*VjL|f5LB#8E+gXky{MJLf&bP-)eH_=`65IsdN(OdKpeMLXfUkngQ zVxSl#28$tLs2C=Oi)4`^Mu?FjRg4m8Vzd||#)@%byqF*+ib-O!m?EZ%X=1vVA!dqn zF-y!AbHrRRPs|q!#6q!1EEY?|Qn5^g=gknyMW$FGR*F?(wOAw8igjYW*dR8FO=7c< z*dnq-w%97RiS1&C*eQ029I;#M5!Z?9#a?lPxKZSao5aoH7O_vNZc##6ZeY;#Dn4?@vt~79ubd<$He2}32{U`DWc*j@w9kGJS(0P&x@nt zn0P_FC|(jTAK`e;@P+a3=)O~LruGZ-mAJP;Z-?Fqy&Js}cXmv}aG#WTHuPTT z{m=)Y4@2idAB8>+oj;V6ctKu0dLi^l=+n@}&}X5~Ltlixj3yoZ>fpt&m$(1x&^OV% z{g?VT33I~9OQCN=--RxRz7PEn$_xD%x)S;+^mFK!(66E2q6sH|kKL7fI6c2~?(nqy zmeI9o`EANvnqcj%wczoGv^|8LJrkK}|*0aMV#m_nwo zDPoG6Vy3t$VM>}9)G#$oEmPanF?CHn zQ{OZ&4NW7{*fcRsO*7Nnv@k7AE7RJvF>OsdlVIAL4yL0?G@VRm)5UZ(-As4W!}K)0 zOmEZ2^fmoVe>1=&nSo}I8El4_p=OvFZjw!k8DU16R5Qw?nbBs98EeLw@n(XVXeOD- zW{R0=rkUwxhM8%ueSuj%%{Ft)Tr Date: Tue, 3 Oct 2017 14:24:45 -0500 Subject: [PATCH 07/15] feature(global-errors): hook up global errors reducer to component and set error on transaction fail --- app/components/GlobalError/GlobalError.js | 7 ++-- app/components/GlobalError/GlobalError.scss | 24 +++++++++++ app/lnd/methods/index.js | 5 ++- app/reducers/error.js | 45 +++++++++++++++++++++ app/reducers/index.js | 4 +- app/reducers/transaction.js | 4 +- app/routes/app/components/App.js | 4 +- app/routes/app/containers/AppContainer.js | 2 + 8 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 app/reducers/error.js diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index a5cb0fec..63a4f0a7 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -1,12 +1,13 @@ import React from 'react' import PropTypes from 'prop-types' -import styles from './GlobalError' +import styles from './GlobalError.scss' const GlobalError = ({ error }) => { console.log('error: ', error) + if (!error) { return null } return ( -
- yo global error mf +
+

{error}

) } diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss index e69de29b..4e0dad23 100644 --- a/app/components/GlobalError/GlobalError.scss +++ b/app/components/GlobalError/GlobalError.scss @@ -0,0 +1,24 @@ +@import '../../variables.scss'; + +.container { + position: absolute; + z-index: 1001; + background: $red; + color: $white; + width: 100%; + text-align: center; + padding: 20px; + // height: 0; + transition: all 0.25s ease; + + &.active { + height: 100%; + padding: 20px; + } + + h2 { + font-size: 20px; + letter-spacing: 1.5px; + font-weight: bold; + } +} \ No newline at end of file diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index ff26b1a7..2b51fa71 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -119,7 +119,10 @@ export default function (lnd, event, msg, data) { // { amount, addr } = data walletController.sendCoins(lnd, data) .then(({ txid }) => event.sender.send('transactionSuccessful', { amount: data.amount, addr: data.addr, txid })) - .catch(error => event.sender.send('transactionError', { error })) + .catch(error => { + console.log('error: ', error) + event.sender.send('transactionError', { error: error.toString() }) + }) break case 'openChannel': // Response is empty. Streaming updates on channel status and updates diff --git a/app/reducers/error.js b/app/reducers/error.js new file mode 100644 index 00000000..8f3404fd --- /dev/null +++ b/app/reducers/error.js @@ -0,0 +1,45 @@ +// ------------------------------------ +// Initial State +// ------------------------------------ +const initialState = { + error: null +} + +// ------------------------------------ +// Constants +// ------------------------------------ +export const SET_ERROR = 'SET_ERROR' +export const CLEAR_ERROR = 'CLEAR_ERROR' + +// ------------------------------------ +// Actions +// ------------------------------------ +export function setError(error) { + return { + type: SET_ERROR, + error + } +} + +export function clearError() { + return { + type: CLEAR_ERROR + } +} + +// ------------------------------------ +// Action Handlers +// ------------------------------------ +const ACTION_HANDLERS = { + [SET_ERROR]: (state, { error }) => ({ ...state, error }), + [CLEAR_ERROR]: () => (initialState) +} + +// ------------------------------------ +// Reducer +// ------------------------------------ +export default function errorReducer(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 7761bece..20e0893b 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -18,6 +18,7 @@ import modal from './modal' import address from './address' import transaction from './transaction' import activity from './activity' +import error from './error' const rootReducer = combineReducers({ router, @@ -37,7 +38,8 @@ const rootReducer = combineReducers({ modal, address, transaction, - activity + activity, + error }) export default rootReducer diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 33821551..62b446e4 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -5,6 +5,7 @@ import { fetchBalance } from './balance' import { setFormType } from './form' import { resetPayForm } from './payform' import { showModal } from './modal' +import { setError } from './error' // ------------------------------------ // Constants @@ -67,8 +68,9 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc dispatch(resetPayForm()) } -export const transactionError = () => (dispatch) => { +export const transactionError = (event, { error }) => (dispatch) => { dispatch({ type: TRANSACTION_FAILED }) + dispatch(setError(error)) } // Listener for when a new transaction is pushed from the subscriber diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index e48d0736..ed38a3a6 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -41,6 +41,8 @@ class App extends Component { formProps, closeForm, + error: { error }, + children } = this.props @@ -58,7 +60,7 @@ class App extends Component { return (
- + ({ invoice: state.invoice, modal: state.modal, + error: state.error, + currentTicker: tickerSelectors.currentTicker(state), isOnchain: payFormSelectors.isOnchain(state), isLn: payFormSelectors.isLn(state), From a6d274aa370a40726ec7ba6f401b2812dd7a122a Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 4 Oct 2017 11:49:30 -0500 Subject: [PATCH 08/15] fix(channels): force close channels --- app/components/GlobalError/GlobalError.js | 5 +++-- app/lnd/methods/channelController.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index 63a4f0a7..a0e8b2ab 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types' import styles from './GlobalError.scss' const GlobalError = ({ error }) => { - console.log('error: ', error) if (!error) { return null } return (
@@ -12,6 +11,8 @@ const GlobalError = ({ error }) => { ) } -GlobalError.propTypes = {} +GlobalError.propTypes = { + error: PropTypes.string +} export default GlobalError diff --git a/app/lnd/methods/channelController.js b/app/lnd/methods/channelController.js index a508904b..dd328ad0 100644 --- a/app/lnd/methods/channelController.js +++ b/app/lnd/methods/channelController.js @@ -72,7 +72,8 @@ export function closeChannel(lnd, event, payload) { channel_point: { funding_txid: BufferUtil.hexToBuffer(tx), output_index: Number(payload.channel_point.output_index) - } + }, + force: true } return new Promise((resolve, reject) => From 5a3c289b726fec79b0d0ecbf819a47fdc336a2a8 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 25 Oct 2017 12:11:08 -0500 Subject: [PATCH 09/15] resolve merge conflict --- app/components/GlobalError/GlobalError.js | 19 +++++++++------ app/components/GlobalError/GlobalError.scss | 26 ++++++++++++++------- app/routes/app/components/App.js | 3 ++- app/routes/app/containers/AppContainer.js | 6 +++++ 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index a0e8b2ab..75f09a1e 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -1,18 +1,23 @@ import React from 'react' import PropTypes from 'prop-types' +import { MdClose } from 'react-icons/lib/md' import styles from './GlobalError.scss' -const GlobalError = ({ error }) => { - if (!error) { return null } - return ( -
+const GlobalError = ({ error, clearError }) => ( +
+
+
+ +

{error}

- ) -} +
+) + GlobalError.propTypes = { - error: PropTypes.string + error: PropTypes.string, + clearError: PropTypes.func.isRequired } export default GlobalError diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss index 4e0dad23..5486c7fc 100644 --- a/app/components/GlobalError/GlobalError.scss +++ b/app/components/GlobalError/GlobalError.scss @@ -8,17 +8,27 @@ width: 100%; text-align: center; padding: 20px; - // height: 0; transition: all 0.25s ease; - &.active { - height: 100%; - padding: 20px; + &.closed { + max-height: 0; + padding: 0; } - h2 { - font-size: 20px; - letter-spacing: 1.5px; - font-weight: bold; + .content { + position: relative; + + .close { + position: absolute; + top: calc(50% - 8px); + right: 10%; + cursor: pointer; + } + + h2 { + font-size: 20px; + letter-spacing: 1.5px; + font-weight: bold; + } } } \ No newline at end of file diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index ed38a3a6..f1485478 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -42,6 +42,7 @@ class App extends Component { closeForm, error: { error }, + clearError, children } = this.props @@ -60,7 +61,7 @@ class App extends Component { return (
- + >>>>>> feature(globalerror): clear error } const mapStateToProps = state => ({ From 794194e86f26dc9c7a1a43de316ed1979533f42c Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 4 Oct 2017 18:35:58 -0500 Subject: [PATCH 10/15] fix(payform): input styles --- app/components/Form/PayForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/Form/PayForm.js b/app/components/Form/PayForm.js index 3d93da5f..5f84cc71 100644 --- a/app/components/Form/PayForm.js +++ b/app/components/Form/PayForm.js @@ -63,7 +63,7 @@ class PayForm extends Component { isLn ? { width: '75%', fontSize: '85px' } : - { width: `${amount.length > 1 ? (amount.length * 15) - 5 : 25}%`, fontSize: `${190 - (amount.length ** 2)}px` } + { width: `${amount.length > 1 ? (amount.length * 20) - 5 : 25}%`, fontSize: `${190 - (amount.length ** 2)}px` } } value={currentAmount} onChange={event => setPayAmount(event.target.value)} From 85ea73819c1b968f861fedd4c55a38fd5428d841 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Thu, 5 Oct 2017 13:36:02 -0500 Subject: [PATCH 11/15] feature(channel-error): display global error for channel error --- app/components/Channels/ChannelForm.js | 2 +- app/lnd/push/openchannel.js | 2 +- app/reducers/channels.js | 15 +++++++++++---- webpack.config.renderer.dev.js | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/components/Channels/ChannelForm.js b/app/components/Channels/ChannelForm.js index 816cf48b..5334af6f 100644 --- a/app/components/Channels/ChannelForm.js +++ b/app/components/Channels/ChannelForm.js @@ -14,7 +14,7 @@ const ChannelForm = ({ form, setForm, ticker, peers, openChannel, currentTicker const pushamt = ticker.currency === 'usd' ? btc.btcToSatoshis(usd.usdToBtc(push_amt, currentTicker.price_usd)) : btc.btcToSatoshis(push_amt) openChannel({ pubkey: node_key, localamt, pushamt }) - setForm({ isOpen: false }) + // setForm({ isOpen: false }) } const customStyles = { diff --git a/app/lnd/push/openchannel.js b/app/lnd/push/openchannel.js index a2df85b2..7bf8958a 100644 --- a/app/lnd/push/openchannel.js +++ b/app/lnd/push/openchannel.js @@ -5,7 +5,7 @@ export default function pushopenchannel(lnd, event, payload) { call.on('data', data => event.sender.send('pushchannelupdated', { data })) call.on('end', () => event.sender.send('pushchannelend')) - call.on('error', error => event.sender.send('pushchannelerror', { error })) + call.on('error', error => event.sender.send('pushchannelerror', { error: error.toString() })) call.on('status', status => event.sender.send('pushchannelstatus', { status })) resolve(null, payload) diff --git a/app/reducers/channels.js b/app/reducers/channels.js index b0a9f20c..863c4156 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -1,5 +1,6 @@ import { createSelector } from 'reselect' import { ipcRenderer } from 'electron' +import { setError } from './error' // ------------------------------------ // Constants // ------------------------------------ @@ -89,21 +90,25 @@ export const channelSuccessful = () => (dispatch) => { // Receive IPC event for updated channel export const pushchannelupdated = () => (dispatch) => { + console.log('channelUpdatedData: ', channelUpdatedData) dispatch(fetchChannels()) } // Receive IPC event for channel end -export const pushchannelend = () => (dispatch) => { +export const pushchannelend = (event, channelEndData) => (dispatch) => { + console.log('channelEndData: ', channelEndData) dispatch(fetchChannels()) } // Receive IPC event for channel error -export const pushchannelerror = () => (dispatch) => { - dispatch(fetchChannels()) +export const pushchannelerror = (event, { error }) => (dispatch) => { + dispatch(openingFailure()) + dispatch(setError(error)) } // Receive IPC event for channel status -export const pushchannelstatus = () => (dispatch) => { +export const pushchannelstatus = (event, channelStatusData) => (dispatch) => { + console.log('channel Status data: ', channelStatusData) dispatch(fetchChannels()) } @@ -168,6 +173,8 @@ const ACTION_HANDLERS = { ), [OPENING_CHANNEL]: state => ({ ...state, openingChannel: true }), + [OPENING_FAILURE]: state => ({ ...state, openingChannel: false }), + [CLOSING_CHANNEL]: state => ({ ...state, closingChannel: true }) } diff --git a/webpack.config.renderer.dev.js b/webpack.config.renderer.dev.js index 02625bed..b76b554c 100644 --- a/webpack.config.renderer.dev.js +++ b/webpack.config.renderer.dev.js @@ -25,6 +25,7 @@ const publicPath = `http://localhost:${port}/dist`; const dll = path.resolve(process.cwd(), 'dll'); const manifest = path.resolve(dll, 'renderer.json'); +console.log('one') /** * Warn if the DLL is not built */ @@ -35,6 +36,8 @@ if (!(fs.existsSync(dll) && fs.existsSync(manifest))) { execSync('npm run build-dll'); } +console.log('two') + export default merge.smart(baseConfig, { devtool: 'inline-source-map', @@ -279,3 +282,5 @@ export default merge.smart(baseConfig, { } } }); + +console.log('three') From 3dedf6c522731c29134adc0416dbf1679466309e Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 25 Oct 2017 12:26:19 -0500 Subject: [PATCH 12/15] feature(payment error): error handling for LN payment --- app/components/GlobalError/GlobalError.js | 19 +++++++++++-------- app/lnd/methods/index.js | 5 ++++- app/reducers/ipc.js | 3 ++- app/reducers/payment.js | 13 +++++++------ app/reducers/transaction.js | 1 + app/routes/app/containers/AppContainer.js | 10 ++-------- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index 75f09a1e..cf566b03 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -3,16 +3,19 @@ import PropTypes from 'prop-types' import { MdClose } from 'react-icons/lib/md' import styles from './GlobalError.scss' -const GlobalError = ({ error, clearError }) => ( -
-
-
- +const GlobalError = ({ error, clearError }) => { + console.log('error: ', error) + return ( +
+
+
+ +
+

{error}

-

{error}

-
-) + ) +} GlobalError.propTypes = { diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index 2b51fa71..609db7c0 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -112,7 +112,10 @@ export default function (lnd, event, msg, data) { // { paymentRequest } = data paymentsController.sendPaymentSync(lnd, data) .then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route }))) - .catch(error => console.log('payinvoice error: ', error)) + .catch(error => { + console.log('payinvoice error: ', error) + event.sender.send('paymentFailed', { error: error.toString() }) + }) break case 'sendCoins': // Transaction looks like { txid: String } diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js index a0789e30..544d6820 100644 --- a/app/reducers/ipc.js +++ b/app/reducers/ipc.js @@ -21,7 +21,7 @@ import { } from './channels' import { lightningPaymentUri } from './payform' -import { receivePayments, paymentSuccessful } from './payment' +import { receivePayments, paymentSuccessful, paymentFailed } from './payment' import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice' import { receiveBalance } from './balance' import { @@ -55,6 +55,7 @@ const ipc = createIpc({ lightningPaymentUri, paymentSuccessful, + paymentFailed, channelSuccessful, pushchannelupdated, diff --git a/app/reducers/payment.js b/app/reducers/payment.js index 795e88ea..0ef8024d 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -4,6 +4,7 @@ import { fetchBalance } from './balance' import { setFormType } from './form' import { resetPayForm } from './payform' import { showModal } from './modal' +import { setError } from './error' // ------------------------------------ // Constants @@ -47,12 +48,6 @@ export function paymentSuccessfull(payment) { } } -export function paymentFailed() { - return { - type: PAYMENT_FAILED - } -} - // Send IPC event for payments export const fetchPayments = () => (dispatch) => { dispatch(getPayments()) @@ -87,6 +82,12 @@ export const paymentSuccessful = () => (dispatch) => { dispatch(fetchBalance()) } +export const paymentFailed = (event, { error }) => (dispatch) => { + dispatch({ type: PAYMENT_FAILED }) + console.log('error: ', error) + dispatch(setError(error)) +} + // ------------------------------------ // Action Handlers diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 62b446e4..2d007e9c 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -70,6 +70,7 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc export const transactionError = (event, { error }) => (dispatch) => { dispatch({ type: TRANSACTION_FAILED }) + console.log('error: ', error) dispatch(setError(error)) } diff --git a/app/routes/app/containers/AppContainer.js b/app/routes/app/containers/AppContainer.js index 66ffa42a..3b86d34b 100644 --- a/app/routes/app/containers/AppContainer.js +++ b/app/routes/app/containers/AppContainer.js @@ -49,15 +49,9 @@ const mapDispatchToProps = { createInvoice, fetchInvoice, -<<<<<<< HEAD -<<<<<<< HEAD - fetchBlockHeight -======= + fetchBlockHeight, + clearError, clearError ->>>>>>> feature(globalerror): clear error -======= - clearError ->>>>>>> 46b03abc5a79d74487165abf8656e69da020f3bc } const mapStateToProps = state => ({ From ed11aaa460a5dca60d5f40d79df7555435fec29c Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 25 Oct 2017 12:36:23 -0500 Subject: [PATCH 13/15] feature(connect peer error): hook up global error handling for connecting to a peer --- app/lnd/methods/index.js | 5 ++++- app/reducers/ipc.js | 3 ++- app/reducers/payment.js | 1 - app/reducers/peers.js | 13 +++++++------ app/reducers/transaction.js | 1 - 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index 609db7c0..193ed793 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -155,7 +155,10 @@ export default function (lnd, event, msg, data) { console.log('peer_id: ', peer_id) event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, peer_id }) }) - .catch(error => console.log('connectPeer error: ', error)) + .catch(error => { + event.sender.send('connectFailure', { error: error.toString() }) + console.log('connectPeer error: ', error) + }) break case 'disconnectPeer': // Empty response. Pass back pubkey on success to remove it from the peers list diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js index 544d6820..f2cea7a7 100644 --- a/app/reducers/ipc.js +++ b/app/reducers/ipc.js @@ -3,7 +3,7 @@ import { lndSyncing, lndSynced, lndStdout } from './lnd' import { receiveInfo } from './info' import { receiveAddress } from './address' import { receiveCryptocurrency } from './ticker' -import { receivePeers, connectSuccess, disconnectSuccess } from './peers' +import { receivePeers, connectSuccess, disconnectSuccess, connectFailure } from './peers' import { receiveChannels, @@ -69,6 +69,7 @@ const ipc = createIpc({ pushclosechannelstatus, connectSuccess, + connectFailure, disconnectSuccess, receiveAddress, diff --git a/app/reducers/payment.js b/app/reducers/payment.js index 0ef8024d..a3907ca7 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -84,7 +84,6 @@ export const paymentSuccessful = () => (dispatch) => { export const paymentFailed = (event, { error }) => (dispatch) => { dispatch({ type: PAYMENT_FAILED }) - console.log('error: ', error) dispatch(setError(error)) } diff --git a/app/reducers/peers.js b/app/reducers/peers.js index e6aec70e..5b7060f7 100644 --- a/app/reducers/peers.js +++ b/app/reducers/peers.js @@ -1,5 +1,6 @@ import { createSelector } from 'reselect' import { ipcRenderer } from 'electron' +import { setError } from './error' // ------------------------------------ // Constants // ------------------------------------ @@ -27,12 +28,6 @@ export function connectPeer() { } } -export function connectFailure() { - return { - type: CONNECT_FAILURE - } -} - export function disconnectPeer() { return { type: DISCONNECT_PEER @@ -83,6 +78,12 @@ export const connectRequest = ({ pubkey, host }) => (dispatch) => { // Send IPC receive for successfully connecting to a peer export const connectSuccess = (event, peer) => dispatch => dispatch({ type: CONNECT_SUCCESS, peer }) +// Send IPC receive for unsuccessfully connecting to a peer +export const connectFailure = (event, { error }) => dispatch => { + dispatch({ type: CONNECT_FAILURE }) + dispatch(setError(error)) +} + // Send IPC send for disconnecting from a peer export const disconnectRequest = ({ pubkey }) => (dispatch) => { dispatch(disconnectPeer()) diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 2d007e9c..62b446e4 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -70,7 +70,6 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc export const transactionError = (event, { error }) => (dispatch) => { dispatch({ type: TRANSACTION_FAILED }) - console.log('error: ', error) dispatch(setError(error)) } From e80dd918808c4999405310d1039618f3906d03d2 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 25 Oct 2017 12:50:11 -0500 Subject: [PATCH 14/15] feature(request global error): hook up back end global errors for request form --- app/components/GlobalError/GlobalError.js | 20 +++++++++----------- app/lnd/methods/index.js | 5 ++++- app/reducers/invoice.js | 12 ++++++------ app/reducers/ipc.js | 3 ++- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index cf566b03..6fffab17 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -3,19 +3,17 @@ import PropTypes from 'prop-types' import { MdClose } from 'react-icons/lib/md' import styles from './GlobalError.scss' -const GlobalError = ({ error, clearError }) => { - console.log('error: ', error) - return ( -
-
-
- -
-

{error}

+const GlobalError = ({ error, clearError }) => ( +
+
+
+
+

{error}

- ) -} +
+) + GlobalError.propTypes = { diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index 193ed793..0d0dd348 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -105,7 +105,10 @@ export default function (lnd, event, msg, data) { }) ) ) - .catch(error => console.log('addInvoice error: ', error)) + .catch(error => { + console.log('addInvoice error: ', error) + event.sender.send('invoiceFailed', { error: error.toString() }) + }) break case 'sendPayment': // Payment looks like { payment_preimage: Buffer, payment_route: Object } diff --git a/app/reducers/invoice.js b/app/reducers/invoice.js index e151ccf8..795544c9 100644 --- a/app/reducers/invoice.js +++ b/app/reducers/invoice.js @@ -5,6 +5,7 @@ import { fetchBalance } from './balance' import { setFormType } from './form' import { setPayInvoice } from './payform' import { resetRequestForm } from './requestform' +import { setError } from './error' import { showNotification } from '../notifications' import { btc, usd } from '../utils' @@ -71,12 +72,6 @@ export function sendInvoice() { } } -export function invoiceFailed() { - return { - type: INVOICE_FAILED - } -} - // Send IPC event for a specific invoice export const fetchInvoice = payreq => (dispatch) => { dispatch(getInvoice()) @@ -117,6 +112,11 @@ export const createdInvoice = (event, invoice) => (dispatch) => { dispatch(resetRequestForm()) } +export const invoiceFailed = (event, { error }) => dispatch => { + dispatch({ type: INVOICE_FAILED }) + dispatch(setError(error)) +} + // Listen for invoice updates pushed from backend from subscribeToInvoices export const invoiceUpdate = (event, { invoice }) => (dispatch) => { dispatch({ type: UPDATE_INVOICE, invoice }) diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js index f2cea7a7..0b3f7a8f 100644 --- a/app/reducers/ipc.js +++ b/app/reducers/ipc.js @@ -22,7 +22,7 @@ import { } from './channels' import { lightningPaymentUri } from './payform' import { receivePayments, paymentSuccessful, paymentFailed } from './payment' -import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice' +import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate, invoiceFailed } from './invoice' import { receiveBalance } from './balance' import { receiveTransactions, @@ -48,6 +48,7 @@ const ipc = createIpc({ receiveInvoices, receiveInvoice: receiveFormInvoice, createdInvoice, + invoiceFailed, invoiceUpdate, receiveBalance, From 9111934f1d68b25185fe10c2424421b332a5ca4a Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Wed, 25 Oct 2017 13:08:41 -0500 Subject: [PATCH 15/15] fix(activity): add padding to bottom of activity list --- app/routes/activity/components/Activity.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/routes/activity/components/Activity.scss b/app/routes/activity/components/Activity.scss index 241e00c4..c7410ea9 100644 --- a/app/routes/activity/components/Activity.scss +++ b/app/routes/activity/components/Activity.scss @@ -92,6 +92,7 @@ .activityContainer { background: $white; transition: opacity 0.25s; + padding-bottom: 50px; &.pulldown { opacity: 0.15;