Browse Source

fix(sendcoins): copy changes, add sendingPayment state to reducer

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
33ef6434ee
  1. 5
      app/lnd/methods/index.js
  2. 7
      app/reducers/payment.js
  3. 4
      app/routes/app/components/components/Form/components/Pay/Pay.js

5
app/lnd/methods/index.js

@ -97,10 +97,7 @@ export default function (lnd, event, msg, data) {
// Transaction looks like { txid: String }
// { amount, addr } = data
walletController.sendCoins(lnd, data)
.then(({ txid }) => {
console.log('transactionId: ', transactionId)
event.sender.send('sendSuccessful', { amount: data.amount, addr: data.addr, txid })
})
.then(({ txid }) => event.sender.send('sendSuccessful', { amount: data.amount, addr: data.addr, txid }))
.catch(error => console.log('sendcoins error: ', error))
break
case 'openChannel':

7
app/reducers/payment.js

@ -11,6 +11,7 @@ export const GET_PAYMENTS = 'GET_PAYMENTS'
export const RECEIVE_PAYMENTS = 'RECEIVE_PAYMENTS'
export const SEND_PAYMENT = 'SEND_PAYMENT'
export const PAYMENT_SUCCESSFULL = 'PAYMENT_SUCCESSFULL'
export const PAYMENT_FAILED = 'PAYMENT_FAILED'
@ -77,6 +78,8 @@ export const sendSuccessful = (event, { amount, addr, txid }) => dispatch => {
console.log('amount: ', amount)
console.log('addr: ', addr)
console.log('txid: ', txid)
// 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 } })
}
@ -86,9 +89,10 @@ export const sendSuccessful = (event, { amount, addr, txid }) => dispatch => {
const ACTION_HANDLERS = {
[SET_PAYMENT]: (state, { payment }) => ({ ...state, payment }),
[GET_PAYMENTS]: state => ({ ...state, paymentLoading: true }),
[SEND_PAYMENT]: state => ({ ...state, sendingPayment: true }),
[RECEIVE_PAYMENTS]: (state, { payments }) => ({ ...state, paymentLoading: false, payments }),
[PAYMENT_SUCCESSFULL]: (state, { payment }) => (
{ ...state, paymentLoading: false, payments: [payment, ...state.payments] }
{ ...state, sendingPayment: false, payments: [payment, ...state.payments] }
)
}
@ -106,6 +110,7 @@ export { paymentSelectors }
// Reducer
// ------------------------------------
const initialState = {
sendingPayment: false,
paymentLoading: false,
payments: [],
payment: null

4
app/routes/app/components/components/Form/components/Pay/Pay.js

@ -70,11 +70,11 @@ class Pay extends Component {
{(() => {
if (isOnchain) {
return (
<span>{`You're about to send ${onchainAmount} on-chain which should take around 10 minutes`}</span>
<span>{`You're about to send ${onchainAmount} ${currency.toUpperCase()} on-chain which should take around 10 minutes`}</span>
)
} else if (isLn) {
return (
<span>{`You're about to send ${calculateAmount(invoiceAmount)} over the Lightning Network which will be instant`}</span>
<span>{`You're about to send ${calculateAmount(invoiceAmount)} ${currency.toUpperCase()} over the Lightning Network which will be instant`}</span>
)
} else {
return null

Loading…
Cancel
Save