Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit d1b244c

Browse files
author
Andrew Schneider
authored
Merge pull request #1727 from blockchain/feat/pit-cleanup
Feat(Pit cleanup and bug fixes)
2 parents a13ee19 + 25f2ead commit d1b244c

9 files changed

Lines changed: 126 additions & 87 deletions

File tree

packages/blockchain-wallet-v4-frontend/src/data/modules/profile/actionTypes.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@ export const LINK_TO_PIT_ACCOUNT_RESET =
3737
export const SET_LINK_TO_PIT_ACCOUNT_DEEPLINK =
3838
'@DATA.PROFILE.SET_LINK_TO_PIT_ACCOUNT_DEEPLINK'
3939

40-
export const CREATE_LINK_ACCOUNT_ID = '@DATA.PROFILE.CREATE_LINK_ACCOUNT_ID'
41-
export const CREATE_LINK_ACCOUNT_ID_LOADING =
42-
'@DATA.PROFILE.CREATE_LINK_ACCOUNT_ID_LOADING'
43-
export const CREATE_LINK_ACCOUNT_ID_SUCCESS =
44-
'@DATA.PROFILE.CREATE_LINK_ACCOUNT_ID_SUCCESS'
45-
export const CREATE_LINK_ACCOUNT_ID_FAILURE =
46-
'@DATA.PROFILE.CREATE_LINK_ACCOUNT_ID_FAILURE'
47-
48-
export const SHARE_ADDRESSES = '@DATA.PROFILE.SHARE_ADDRESSES'
49-
export const SHARE_ADDRESSES_LOADING = '@DATA.PROFILE.SHARE_ADDRESSES_LOADING'
50-
export const SHARE_ADDRESSES_SUCCESS = '@DATA.PROFILE.SHARE_ADDRESSES_SUCCESS'
51-
export const SHARE_ADDRESSES_FAILURE = '@DATA.PROFILE.SHARE_ADDRESSES_FAILURE'
40+
export const SHARE_WALLET_ADDRESSES_WITH_PIT =
41+
'@DATA.PROFILE.SHARE_WALLET_ADDRESSES_WITH_PIT'
42+
export const SHARE_WALLET_ADDRESSES_WITH_PIT_LOADING =
43+
'@DATA.PROFILE.SHARE_WALLET_ADDRESSES_WITH_PIT_LOADING'
44+
export const SHARE_WALLET_ADDRESSES_WITH_PIT_SUCCESS =
45+
'@DATA.PROFILE.SHARE_WALLET_ADDRESSES_WITH_PIT_SUCCESS'
46+
export const SHARE_WALLET_ADDRESSES_WITH_PIT_FAILURE =
47+
'@DATA.PROFILE.SHARE_WALLET_ADDRESSES_WITH_PIT_FAILURE'

packages/blockchain-wallet-v4-frontend/src/data/modules/profile/actions.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ export const setLinkToPitAccountDeepLink = deeplink => ({
9090
payload: { deeplink }
9191
})
9292

93-
export const shareAddresses = () => ({
94-
type: AT.SHARE_ADDRESSES
93+
export const shareWalletAddressesWithPit = () => ({
94+
type: AT.SHARE_WALLET_ADDRESSES_WITH_PIT
9595
})
96-
export const shareAddressesLoading = () => ({
97-
type: AT.SHARE_ADDRESSES_LOADING
96+
export const shareWalletAddressesWithPitLoading = () => ({
97+
type: AT.SHARE_WALLET_ADDRESSES_WITH_PIT_LOADING
9898
})
99-
export const shareAddressesSuccess = data => ({
100-
type: AT.SHARE_ADDRESSES_SUCCESS,
99+
export const shareWalletAddressesWithPitSuccess = data => ({
100+
type: AT.SHARE_WALLET_ADDRESSES_WITH_PIT_SUCCESS,
101101
payload: { data }
102102
})
103-
export const shareAddressesFailure = e => ({
104-
type: AT.SHARE_ADDRESSES_FAILURE,
103+
export const shareWalletAddressesWithPitFailure = e => ({
104+
type: AT.SHARE_WALLET_ADDRESSES_WITH_PIT_FAILURE,
105105
payload: { e }
106106
})

packages/blockchain-wallet-v4-frontend/src/data/modules/profile/reducers.js

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assoc, compose, merge } from 'ramda'
1+
import { assoc, assocPath, compose, merge } from 'ramda'
22
import * as AT from './actionTypes'
33

44
import { Remote } from 'blockchain-wallet-v4'
@@ -7,11 +7,12 @@ import { INITIAL_TIERS } from './model'
77
const INITIAL_STATE = {
88
apiToken: Remote.NotAsked,
99
campaign: {},
10-
pitLinkId: Remote.NotAsked,
11-
linkFromPitAccountStatus: Remote.NotAsked,
12-
linkToPitAccountDeeplink: null,
13-
linkToPitAccountStatus: Remote.NotAsked,
14-
shareAddresses: Remote.NotAsked,
10+
pitOnboarding: {
11+
linkFromPitAccountStatus: Remote.NotAsked,
12+
linkToPitAccountDeeplink: null,
13+
linkToPitAccountStatus: Remote.NotAsked,
14+
shareWalletAddressesWithPit: Remote.NotAsked
15+
},
1516
userData: Remote.NotAsked,
1617
userTiers: Remote.of(INITIAL_TIERS)
1718
}
@@ -52,34 +53,64 @@ export default (state = INITIAL_STATE, action) => {
5253
state
5354
)
5455
case AT.LINK_FROM_PIT_ACCOUNT_LOADING:
55-
return assoc('linkFromPitAccountStatus', Remote.Loading, state)
56+
return assocPath(
57+
['pitOnboarding', 'linkFromPitAccountStatus'],
58+
Remote.Loading,
59+
state
60+
)
5661
case AT.LINK_FROM_PIT_ACCOUNT_FAILURE:
57-
return assoc('linkFromPitAccountStatus', Remote.Failure(payload.e), state)
62+
return assocPath(
63+
['pitOnboarding', 'linkFromPitAccountStatus'],
64+
Remote.Failure(payload.e),
65+
state
66+
)
5867
case AT.SET_LINK_TO_PIT_ACCOUNT_DEEPLINK:
59-
return assoc('linkToPitAccountDeeplink', payload.deeplink, state)
68+
return assocPath(
69+
['pitOnboarding', 'linkToPitAccountDeeplink'],
70+
payload.deeplink,
71+
state
72+
)
6073
case AT.LINK_TO_PIT_ACCOUNT_RESET:
6174
return compose(
62-
assoc('linkToPitAccountStatus', Remote.NotAsked),
63-
assoc('linkToPitAccountDeeplink', null)
75+
assocPath(['pitOnboarding', 'linkToPitAccountStatus'], Remote.NotAsked),
76+
assocPath(['pitOnboarding', 'linkToPitAccountDeeplink'], null)
6477
)(state)
6578
case AT.LINK_TO_PIT_ACCOUNT_LOADING:
66-
return assoc('linkToPitAccountStatus', Remote.Loading, state)
79+
return assocPath(
80+
['pitOnboarding', 'linkToPitAccountStatus'],
81+
Remote.Loading,
82+
state
83+
)
6784
case AT.LINK_TO_PIT_ACCOUNT_SUCCESS:
68-
return assoc('linkToPitAccountStatus', Remote.Success(payload), state)
85+
return assocPath(
86+
['pitOnboarding', 'linkToPitAccountStatus'],
87+
Remote.Success(payload),
88+
state
89+
)
6990
case AT.LINK_TO_PIT_ACCOUNT_FAILURE:
70-
return assoc('linkToPitAccountStatus', Remote.Failure(payload.e), state)
71-
case AT.CREATE_LINK_ACCOUNT_ID_SUCCESS:
72-
return assoc('pitLinkId', Remote.Success(payload.data), state)
73-
case AT.CREATE_LINK_ACCOUNT_ID_LOADING:
74-
return assoc('pitLinkId', Remote.Loading, state)
75-
case AT.CREATE_LINK_ACCOUNT_ID_FAILURE:
76-
return assoc('pitLinkId', Remote.Failure(payload.e), state)
77-
case AT.SHARE_ADDRESSES_SUCCESS:
78-
return assoc('shareAddresses', Remote.Success(payload.data), state)
79-
case AT.SHARE_ADDRESSES_LOADING:
80-
return assoc('shareAddresses', Remote.Loading, state)
81-
case AT.SHARE_ADDRESSES_FAILURE:
82-
return assoc('shareAddresses', Remote.Failure(payload.e), state)
91+
return assocPath(
92+
['pitOnboarding', 'linkToPitAccountStatus'],
93+
Remote.Failure(payload.e),
94+
state
95+
)
96+
case AT.SHARE_WALLET_ADDRESSES_WITH_PIT_SUCCESS:
97+
return assocPath(
98+
['pitOnboarding', 'shareWalletAddressesWithPit'],
99+
Remote.Success(payload.data),
100+
state
101+
)
102+
case AT.SHARE_WALLET_ADDRESSES_WITH_PIT_LOADING:
103+
return assocPath(
104+
['pitOnboarding', 'shareWalletAddressesWithPit'],
105+
Remote.Loading,
106+
state
107+
)
108+
case AT.SHARE_WALLET_ADDRESSES_WITH_PIT_FAILURE:
109+
return assocPath(
110+
['pitOnboarding', 'shareWalletAddressesWithPit'],
111+
Remote.Failure(payload.e),
112+
state
113+
)
83114
case AT.SET_CAMPAIGN:
84115
return assoc('campaign', payload.campaign, state)
85116
default:

packages/blockchain-wallet-v4-frontend/src/data/modules/profile/sagaRegister.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default ({ api, coreSagas, networks }) => {
88
fetchUser,
99
linkFromPitAccount,
1010
linkToPitAccount,
11-
shareAddresses,
11+
shareWalletAddressesWithPit,
1212
signIn
1313
} = sagas({
1414
api,
@@ -22,6 +22,9 @@ export default ({ api, coreSagas, networks }) => {
2222
yield takeLatest(AT.FETCH_USER, fetchUser)
2323
yield takeLatest(AT.LINK_FROM_PIT_ACCOUNT, linkFromPitAccount)
2424
yield takeLatest(AT.LINK_TO_PIT_ACCOUNT, linkToPitAccount)
25-
yield takeLatest(AT.SHARE_ADDRESSES, shareAddresses)
25+
yield takeLatest(
26+
AT.SHARE_WALLET_ADDRESSES_WITH_PIT,
27+
shareWalletAddressesWithPit
28+
)
2629
}
2730
}

packages/blockchain-wallet-v4-frontend/src/data/modules/profile/sagas.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ export default ({ api, coreSagas, networks }) => {
304304
}
305305
}
306306

307-
const shareAddresses = function * () {
307+
const shareWalletAddressesWithPit = function * () {
308308
try {
309-
yield put(A.shareAddressesLoading())
309+
yield put(A.shareWalletAddressesWithPitLoading())
310310
// TODO: move to goal and pass remaining coins to saga
311311
// Only run saga if remainingCoins is !empty
312312
const supportedCoinsList = (yield select(
@@ -320,7 +320,6 @@ export default ({ api, coreSagas, networks }) => {
320320
supportedCoinsList,
321321
depositAddressesList
322322
)
323-
324323
// BTC
325324
const defaultIdx = yield select(
326325
selectors.core.wallet.getDefaultAccountIndex
@@ -338,40 +337,38 @@ export default ({ api, coreSagas, networks }) => {
338337
const ETH = selectors.core.kvStore.eth.getContext
339338
// XLM
340339
const XLM = selectors.core.kvStore.xlm.getDefaultAccountId
341-
342340
const addressSelectors = { BTC, BCH, ETH, XLM, PAX: ETH }
343-
344341
const state = yield select()
345342
const remainingAddresses = remainingCoins.reduce((res, coin) => {
346343
res[coin] = addressSelectors[coin](state).getOrElse(null)
347344
return res
348345
}, depositAddresses)
349346
const data = yield call(api.shareDepositAddresses, remainingAddresses)
350-
yield put(A.shareAddressesSuccess(data))
347+
yield put(A.shareWalletAddressesWithPitSuccess(data))
351348
} catch (e) {
352-
yield put(A.shareAddressesFailure(e))
349+
yield put(A.shareWalletAddressesWithPitFailure(e))
353350
}
354351
}
355352

356353
const linkFromPitAccount = function * ({ payload }) {
357354
try {
358355
const { linkId } = payload
359356
yield put(A.linkFromPitAccountLoading())
360-
// Check if email is verified
357+
// ensure email is verified else wait
361358
const isEmailVerified = (yield select(
362359
selectors.core.settings.getEmailVerified
363360
)).getOrElse(true)
364-
// If email is not verified wait
365361
if (!isEmailVerified)
366362
yield take(actionTypes.core.settings.SET_EMAIL_VERIFIED)
367-
// Check if user is created
363+
// get or create user
368364
const isUserStateNone = (yield select(S.isUserStateNone)).getOrElse(false)
369-
// If user is not created, create
370365
if (isUserStateNone) yield call(createUser)
371-
// Link Account
366+
// link Account
372367
const data = yield call(api.linkAccount, linkId)
373-
yield put(A.shareAddresses())
368+
yield put(A.shareWalletAddressesWithPit())
374369
yield put(A.linkFromPitAccountSuccess(data))
370+
// update user
371+
yield call(fetchUser)
375372
} catch (e) {
376373
yield put(A.linkFromPitAccountFailure(e))
377374
}
@@ -472,7 +469,7 @@ export default ({ api, coreSagas, networks }) => {
472469
renewSession,
473470
renewUser,
474471
setSession,
475-
shareAddresses,
472+
shareWalletAddressesWithPit,
476473
signIn,
477474
syncUserWithWallet,
478475
updateUser,

packages/blockchain-wallet-v4-frontend/src/data/modules/profile/selectors.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,17 @@ export const closeToTier1Limit = state =>
121121

122122
export const getLinkFromPitAccountStatus = path([
123123
'profile',
124+
'pitOnboarding',
124125
'linkFromPitAccountStatus'
125126
])
126127
export const getLinkToPitAccountStatus = path([
127128
'profile',
129+
'pitOnboarding',
128130
'linkToPitAccountStatus'
129131
])
130132
export const getLinkToPitAccountDeeplink = path([
131133
'profile',
134+
'pitOnboarding',
132135
'linkToPitAccountDeeplink'
133136
])
134137

packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/LinkFromPitAccount/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const mapStateToProps = state => ({
3131
const mapDispatchToProps = dispatch => ({
3232
actions: bindActionCreators(
3333
{
34-
...actions.components.identityVerification,
35-
...actions.modules.profile
34+
...actions.modules.profile,
35+
...actions.modules.securityCenter
3636
},
3737
dispatch
3838
)

packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/LinkFromPitAccount/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const LinkFromPitAccount = ({
170170
nature='purple'
171171
height='56px'
172172
fullwidth
173-
onClick={actions.sendEmailVerification}
173+
onClick={actions.resendVerifyEmail}
174174
>
175175
<Text color='white' size='16px' weight={500}>
176176
<FormattedMessage
Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from 'react'
22
import styled from 'styled-components'
33
import { FormattedMessage } from 'react-intl'
4+
import { connect } from 'react-redux'
45

6+
import { selectors } from 'data'
57
import { Button, Link, Image, Text } from 'blockchain-info-components'
68

79
const Wrapper = styled.div`
@@ -29,28 +31,35 @@ const LearnMoreButton = styled(Button)`
2931
margin-top: 15px;
3032
`
3133

32-
export const ThePitBanner = () => (
33-
<Wrapper>
34-
<PitLogo name='the-pit-word' height='50px' />
35-
<Text color='white' size='16px' weight={400}>
36-
<FormattedMessage
37-
defaultMessage="It's time to Level Up to a better crypto exchange. First 100,000 traders to sign up will trade free for 30 days."
38-
id='scenes.home.thepit.subtitle'
39-
/>
40-
</Text>
41-
<Link
42-
href='https://pit.blockchain.com/'
43-
target='_blank'
44-
rel='noopener noreferrer'
45-
>
46-
<LearnMoreButton nature='purple'>
34+
export const ThePitBanner = ({ isPitAccountLinked }) => {
35+
return !isPitAccountLinked ? (
36+
<Wrapper>
37+
<PitLogo name='the-pit-word' height='50px' />
38+
<Text color='white' size='16px' weight={400}>
4739
<FormattedMessage
48-
id='scenes.home.thepit.learnmore'
49-
defaultMessage='Learn More'
40+
defaultMessage="It's time to Level Up to a better crypto exchange. The first 100,000 traders to sign up will trade free for 30 days."
41+
id='scenes.home.thepit.subtitle'
5042
/>
51-
</LearnMoreButton>
52-
</Link>
53-
</Wrapper>
54-
)
43+
</Text>
44+
<Link
45+
href='https://pit.blockchain.com/'
46+
target='_blank'
47+
rel='noopener noreferrer'
48+
>
49+
<LearnMoreButton nature='purple'>
50+
<FormattedMessage
51+
id='scenes.home.thepit.learnmore'
52+
defaultMessage='Learn More'
53+
/>
54+
</LearnMoreButton>
55+
</Link>
56+
</Wrapper>
57+
) : null
58+
}
59+
const mapStateToProps = state => ({
60+
isPitAccountLinked: selectors.modules.profile
61+
.isPitAccountLinked(state)
62+
.getOrElse(true)
63+
})
5564

56-
export default ThePitBanner
65+
export default connect(mapStateToProps)(ThePitBanner)

0 commit comments

Comments
 (0)