Skip to content

Commit

Permalink
fix(coinify payment)
Browse files Browse the repository at this point in the history
  • Loading branch information
sixtedemaupeou committed May 24, 2018
1 parent 0ebc677 commit e0236f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default ({ coreSagas }) => {

const sell = function * () {
try {
yield put(A.coinifyLoading())
const trade = yield call(coreSagas.data.coinify.sell)
yield put(A.coinifyLoading())

if (!trade) {
const trade = yield select(selectors.core.data.coinify.getTrade)
Expand All @@ -70,9 +70,18 @@ export default ({ coreSagas }) => {
}
const p = yield select(sendBtcSelectors.getPayment)
let payment = yield coreSagas.payment.btc.create(
{ payment: p.getOrElse({}), network: settings.NETWORK_BITCOIN })
{ payment: p.getOrElse({}), network: settings.NETWORK })
payment = yield payment.amount(parseInt(trade.sendAmount))
payment = yield payment.fee('priority')

// QA Tool: manually set a "to" address on the payment object for testing sell
const qaState = yield select()
const qaAddress = path(['qa', 'qaSellAddress'], qaState)

if (qaAddress) {
payment = yield payment.to(qaAddress)
} else {
payment = yield payment.to(trade.receiveAddress)
}
payment = yield payment.to(trade.receiveAddress)
payment = yield payment.description(`Exchange Trade COINIFY=${trade.id}`)

Expand All @@ -85,13 +94,14 @@ export default ({ coreSagas }) => {
yield put(sendBtcActions.sendBtcPaymentUpdated(Remote.of(payment.value())))
const password = yield call(promptForSecondPassword)
payment = yield payment.sign(password)
payment = yield payment.publish
payment = yield payment.publish()

yield put(sendBtcActions.sendBtcPaymentUpdated(Remote.of(payment.value())))

yield put(A.coinifySuccess())
yield put(actions.form.change('buySellTabStatus', 'status', 'order_history'))
} catch (e) {
console.log('Error in coinifysell', e)
yield put(A.coinifyFailure(e))
yield put(actions.logs.logErrorMessage(logLocation, 'sell', e))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class SellContainer extends React.Component {
}

componentDidMount () {
this.props.sendBtcActions.sendBtcInitialized({ feeType: 'priority' })
this.props.coinifyActions.initializeCheckoutForm('sell')
}

submitQuote () {
const { sellQuoteR } = this.props
sellQuoteR.map(quote => this.props.coinifyDataActions.getMediumsWithBankAccounts(quote))
Expand All @@ -24,7 +26,6 @@ class SellContainer extends React.Component {

startSell () {
const { coinifyActions } = this.props
coinifyActions.coinifyLoading()
coinifyActions.initiateSell()
}

Expand Down Expand Up @@ -74,6 +75,7 @@ const mapStateToProps = state => getData(state)

const mapDispatchToProps = dispatch => ({
modalActions: bindActionCreators(actions.modals, dispatch),
sendBtcActions: bindActionCreators(actions.components.sendBtc, dispatch),
coinifyDataActions: bindActionCreators(actions.core.data.coinify, dispatch),
formActions: bindActionCreators(actions.form, dispatch),
coinifyActions: bindActionCreators(actions.modules.coinify, dispatch)
Expand Down

0 comments on commit e0236f2

Please sign in to comment.