Skip to content

Commit

Permalink
feat(send receive): yield user data
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed May 27, 2021
1 parent abbe341 commit 58178ff
Showing 1 changed file with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
call,
CallEffect,
put,
PutEffect,
select,
SelectEffect
} from 'redux-saga/effects'
import { call, CallEffect, put, PutEffect, select, SelectEffect } from 'redux-saga/effects'

import { APIType } from 'blockchain-wallet-v4/src/network/api'
import { errorHandler } from 'blockchain-wallet-v4/src/utils'
Expand All @@ -18,23 +11,15 @@ import * as A from './actions'
import { RequestExtrasType } from './types'
import { generateKey } from './utils'

export default ({
api,
coreSagas,
networks
}: {
api: APIType
coreSagas: any
networks: any
}) => {
export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; networks: any }) => {
// const logLocation = 'components/request/sagas'
const { waitForUserData } = profileSagas({ api, coreSagas, networks })
const { getNextReceiveAddressForCoin } = coinSagas({
coreSagas,
networks
})

const getNextAddress = function * (
const getNextAddress = function* (
action: ReturnType<typeof A.getNextAddress>
): Generator<CallEffect | PutEffect | SelectEffect, void, any> {
const key = generateKey(action.payload.account)
Expand All @@ -44,16 +29,16 @@ export default ({
try {
yield put(A.getNextAddressLoading(key))
let address
let extras: RequestExtrasType = {}
const account = action.payload.account
const extras: RequestExtrasType = {}
const { account } = action.payload

switch (account.type) {
case 'ACCOUNT':
const { accountIndex, coin } = account
address = yield call(getNextReceiveAddressForCoin, coin, accountIndex)
break
case 'CUSTODIAL':
waitForUserData()
yield call(waitForUserData)
const custodial: ReturnType<typeof api.getSBPaymentAccount> = yield call(
api.getSBPaymentAccount,
account.coin
Expand All @@ -63,6 +48,8 @@ export default ({
extras.Memo = address.split(':')[1]
address = address.split(':')[0]
}
break
default:
}

yield put(A.getNextAddressSuccess(key, address, extras))
Expand Down

0 comments on commit 58178ff

Please sign in to comment.