Skip to content

Commit

Permalink
fix(xlm-interest): fetch placeholder deposit address
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Apr 21, 2021
1 parent 59723af commit a5f8062
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default ({
])
}
// non-custodial deposit
// fetch deposit address
// fetch deposit address to build provisional payment
yield put(A.fetchInterestAccount(coin))
yield take([
AT.FETCH_INTEREST_PAYMENT_ACCOUNT_SUCCESS,
Expand Down Expand Up @@ -304,16 +304,16 @@ export default ({
coin,
Remote.of(payment)
)
newPayment = newPayment.to(depositAddress, 'ADDRESS')
debugger
newPayment = newPayment.to(depositAddress, 'ADDRESS').value()

const custodialBalances = isFromBuySell
? (yield select(selectors.components.simpleBuy.getSBBalances)).getOrFail(
'Failed to get balance'
)
: null

yield call(createLimits, newPayment.value(), custodialBalances)
yield put(A.setPaymentSuccess(newPayment.value()))
yield call(createLimits, newPayment, custodialBalances)
yield put(A.setPaymentSuccess(newPayment))
let additionalParameters = {}
if (isFromBuySell) {
yield put(A.setCoinDisplay(true))
Expand Down Expand Up @@ -419,12 +419,26 @@ export default ({
origin: 'SIMPLEBUY'
})
} else {
// non-custodial deposit
// fetch deposit address
yield put(A.fetchInterestAccount(coin))
yield take([
AT.FETCH_INTEREST_PAYMENT_ACCOUNT_SUCCESS,
AT.FETCH_INTEREST_PAYMENT_ACCOUNT_FAILURE
])
const depositAddress = yield select(S.getDepositAddress)

// abort if deposit address missing
if (isEmpty(depositAddress) || isNil(depositAddress)) {
throw new Error('Missing deposit address')
}

// build and publish payment to network
const transaction = yield call(
buildAndPublishPayment,
coin,
payment,
payment.to()
depositAddress
)
// notify backend of incoming non-custodial deposit
yield put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,40 +133,6 @@ export default ({ coreSagas, networks }: { coreSagas: any; networks: any }) => {
return payment
}

// const createInitialProvisionalPayment = function * (
// coin: CoinType,
// payment: PaymentType,
// destination: string
// ): Generator<PaymentType | CallEffect, PaymentValue, any> {
// try {
// if (coin === 'XLM') {
// // separate out addresses and memo
// const depositAddressMemo = destination.split(':')
// const txMemo = depositAddressMemo[1]
// // throw error if we cant parse the memo for tx
// if (
// isNil(txMemo) ||
// (typeof txMemo === 'string' && txMemo.length === 0)
// ) {
// throw new Error('Memo for transaction is missing')
// }
// payment = yield payment.to(depositAddressMemo[0], 'CUSTODIAL')
// // @ts-ignore
// payment = yield payment.memo(txMemo)
// // @ts-ignore
// payment = yield payment.memoType('text')
// // @ts-ignore
// payment = yield payment.setDestinationAccountExists(true)
// } else {
// payment = yield payment.to(destination, 'CUSTODIAL')
// }
// } catch (e) {
// throw e
// }

// return payment.value()
// }

const toCustodialDropdown = currencyDetails => {
// this object has to be equal to object we do expect in dropdown
const { ...restDetails } = currencyDetails
Expand Down

0 comments on commit a5f8062

Please sign in to comment.